ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Fill with a formula until Cell is Blank (https://www.excelbanter.com/excel-programming/300675-fill-formula-until-cell-blank.html)

John

Fill with a formula until Cell is Blank
 
What code would I use to copy a formula down until Column A.. is blank. I
can copy etc but don't know what code to use that identifies that Column A
is blank


Thanks




pikus

Fill with a formula until Cell is Blank
 
Range("C1").Copy
x = 2
Do Until Cells(x, 1).Value = ""
Cells(x, 3).PasteSpecial xlPasteFormulas
x = x + 1
Loop

- Piku

--
Message posted from http://www.ExcelForum.com


John

Fill with a formula until Cell is Blank
 
I'm still having a problem, it hits debug on my second line i..e
ActiveCell.FormulaR1C1 = "=VLOOKUP($C2,Master_Menu_Item_Nos,3,0)*$E2"




Sub Format_Query()


Sheets("Sales Mix").Select


Range("F2").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP($C2,Master_Menu_Item_Nos,3,0)*$E2"
Range("G2").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP($C2,Master_Menu_Item_Nos,4,0)*$E2"
Range("H2").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP($C2,Master_Menu_Item_Nos,5,0)*$E2"
Range("I2").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP($C2,Master_Menu_Item_Nos,6,0)*$E2"
Range("J2").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP($C2,Master_Menu_Item_Nos,7,0)*$E2"


Range("F2.J2").Copy
x = 2
Do Until Cells(x, 1).Value = ""
Cells(x, 3).PasteSpecial xlPasteFormulas
x = x + 1
Loop


Range("A1").Select

End Sub


"pikus " wrote in message
...
Range("C1").Copy
x = 2
Do Until Cells(x, 1).Value = ""
Cells(x, 3).PasteSpecial xlPasteFormulas
x = x + 1
Loop

- Pikus


---
Message posted from http://www.ExcelForum.com/




Cecilkumara Fernando[_2_]

Fill with a formula until Cell is Blank
 
use ActiveCell.Formula =
instead of
ActiveCell.FormulaR1C1 =

"John" wrote in message
...
I'm still having a problem, it hits debug on my second line i..e
ActiveCell.FormulaR1C1 = "=VLOOKUP($C2,Master_Menu_Item_Nos,3,0)*$E2"




Sub Format_Query()


Sheets("Sales Mix").Select


Range("F2").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP($C2,Master_Menu_Item_Nos,3,0)*$E2"
Range("G2").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP($C2,Master_Menu_Item_Nos,4,0)*$E2"
Range("H2").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP($C2,Master_Menu_Item_Nos,5,0)*$E2"
Range("I2").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP($C2,Master_Menu_Item_Nos,6,0)*$E2"
Range("J2").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP($C2,Master_Menu_Item_Nos,7,0)*$E2"


Range("F2.J2").Copy
x = 2
Do Until Cells(x, 1).Value = ""
Cells(x, 3).PasteSpecial xlPasteFormulas
x = x + 1
Loop


Range("A1").Select

End Sub


"pikus " wrote in message
...
Range("C1").Copy
x = 2
Do Until Cells(x, 1).Value = ""
Cells(x, 3).PasteSpecial xlPasteFormulas
x = x + 1
Loop

- Pikus


---
Message posted from http://www.ExcelForum.com/






John[_78_]

Fill with a formula until Cell is Blank
 
Thanks for the reply, I just recorded the macro and used that recorded code


"Cecilkumara Fernando" <cekufdo@sltnetDOTlk wrote in message
...
use ActiveCell.Formula =
instead of
ActiveCell.FormulaR1C1 =

"John" wrote in message
...
I'm still having a problem, it hits debug on my second line i..e
ActiveCell.FormulaR1C1 = "=VLOOKUP($C2,Master_Menu_Item_Nos,3,0)*$E2"




Sub Format_Query()


Sheets("Sales Mix").Select


Range("F2").Select
ActiveCell.FormulaR1C1 =

"=VLOOKUP($C2,Master_Menu_Item_Nos,3,0)*$E2"
Range("G2").Select
ActiveCell.FormulaR1C1 =

"=VLOOKUP($C2,Master_Menu_Item_Nos,4,0)*$E2"
Range("H2").Select
ActiveCell.FormulaR1C1 =

"=VLOOKUP($C2,Master_Menu_Item_Nos,5,0)*$E2"
Range("I2").Select
ActiveCell.FormulaR1C1 =

"=VLOOKUP($C2,Master_Menu_Item_Nos,6,0)*$E2"
Range("J2").Select
ActiveCell.FormulaR1C1 =

"=VLOOKUP($C2,Master_Menu_Item_Nos,7,0)*$E2"


Range("F2.J2").Copy
x = 2
Do Until Cells(x, 1).Value = ""
Cells(x, 3).PasteSpecial xlPasteFormulas
x = x + 1
Loop


Range("A1").Select

End Sub


"pikus " wrote in message
...
Range("C1").Copy
x = 2
Do Until Cells(x, 1).Value = ""
Cells(x, 3).PasteSpecial xlPasteFormulas
x = x + 1
Loop

- Pikus


---
Message posted from http://www.ExcelForum.com/









All times are GMT +1. The time now is 12:19 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com