< návrat zpět

MS Excel


Téma: Cyklický vzorec rss

Zaslal/a 18.9.2011 13:16

Dobry den,
jakym zpusobem lze pomoci makra vyresit „cyklicky“ vzorec A1=A1+B2, tedy krokove:
1) Secti A1+B2
2) A1 prepis vyslednou hodnotou
3) B2 vymaz hodnotu
Diky za pomoc, s makrem jsem doposud prisel do styku pouze jako user..

Zaslat odpověď >

#005997
Stalker
Co takhle:
Sub secti()
'sečte hodnoty v buňkých A1 a B2
Soucet = Range("A1").Value + Range("B2").Value
'do buňky A1 zapíše součet buněk A1 a B2
Range("A1").Value = Soucet
'vymaže hodnotu v buňce B2
Range("B2").ClearContents

End Sub
Příloha: rar5997_soucet.rar (9kB, staženo 15x)
citovat
#005998
avatar
Diky, funguje to skvele!!
Male doplneni:
Je mozne "hromadne" scitani (A1-A10 secti s B2-B10) nebo musim makro 10x rozkopirovat?

OndraScitovat
icon #006003
Poki
jde temer vsechno, jen presne vedet, co vlastne chcete... :-) - a pak se taky presne zeptat.

Takze, chcete secist oblast A1 az A10 a pak k tomu jeste pricist B1 az B10?
nebo chcete mit matici deseti souctu (A1+B1;A2+B2...)?citovat
#006005
avatar
Omlouvam se, jedna se opravdu o matici deseti souctu..
V tuto chvili jsem to "vyresil" mnohonasobnym rozkopirovanim kodu:


Sub Změna_EUR()
Soucet = Range("B5").Value + Range("I5").Value
Range("B5").Value = Soucet
Range("I5").ClearContents
Soucet = Range("B6").Value + Range("I6").Value
Range("B6").Value = Soucet
Range("I6").ClearContents
Soucet = Range("B7").Value + Range("I7").Value
Range("B7").Value = Soucet
Range("I7").ClearContents
Soucet = Range("B8").Value + Range("I8").Value
Range("B8").Value = Soucet
Range("I8").ClearContents
Soucet = Range("B9").Value + Range("I9").Value
Range("B9").Value = Soucet
Range("I9").ClearContents
Soucet = Range("B10").Value + Range("I10").Value
Range("B10").Value = Soucet
Range("I10").ClearContents
Soucet = Range("B11").Value + Range("I11").Value
Range("B11").Value = Soucet
Range("I11").ClearContents
Soucet = Range("B12").Value + Range("I12").Value
Range("B12").Value = Soucet
Range("I12").ClearContents
Soucet = Range("B13").Value + Range("I13").Value
Range("B13").Value = Soucet
Range("I13").ClearContents

Soucet = Range("D5").Value + Range("J5").Value
Range("D5").Value = Soucet
Range("J5").ClearContents
Soucet = Range("D6").Value + Range("J6").Value
Range("D6").Value = Soucet
Range("J6").ClearContents
Soucet = Range("D7").Value + Range("J7").Value
Range("D7").Value = Soucet
Range("J7").ClearContents
Soucet = Range("D8").Value + Range("J8").Value
Range("D8").Value = Soucet
Range("J8").ClearContents
Soucet = Range("D9").Value + Range("J9").Value
Range("D9").Value = Soucet
Range("J9").ClearContents
Soucet = Range("D10").Value + Range("J10").Value
Range("D10").Value = Soucet
Range("J10").ClearContents
Soucet = Range("D11").Value + Range("J11").Value
Range("D11").Value = Soucet
Range("J11").ClearContents
Soucet = Range("D12").Value + Range("J12").Value
Range("D12").Value = Soucet
Range("J12").ClearContents
Soucet = Range("D13").Value + Range("J13").Value
Range("D13").Value = Soucet
Range("J13").ClearContents

End Sub
citovat
icon #006006
Poki
nechtelo se mi ten strasne dlouhej kod moc studovat, ale myslim, ze by to slo zapsat takto:
Sub secti()
Dim i As Long

' sloupce B a I
For i = 5 To 13
Cells(i, 2) = Cells(i, 2) + Cells(i, 9)
Cells(i, 9).ClearContents
Next i

' sloupce D a J
For i = 5 To 13
Cells(i, 4) = Cells(i, 4) + Cells(i, 10)
Cells(i, 10).ClearContents
Next i
End Sub
citovat
#006007
avatar
Plně funkční!!

Obě moc děkuji za pomoc !!

OndraScitovat

Uživatelské menu

Nejste přihlášen(a)
avatar\n

Menu

On-line nástroje

Formulář Faktura

Formulář Faktura IV

Oblíbený formulář Faktura byl vylepšen a rozšířen.
Více se dočtete zde.

Aktivní diskuse

Čas od do

lubo • 19.4. 16:30

Makro smyčka

MilanKop • 19.4. 10:46

Makro smyčka

elninoslov • 19.4. 9:02

Čas od do

elninoslov • 19.4. 8:46

Čas od do

jarek1111 • 18.4. 13:46

Čas od do

lubo • 18.4. 11:13

Čas od do

jarek1111 • 18.4. 8:32