Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
I have a formula in cell C2. I want to create a macro in VBA to fill down
that formula into cells C3:C100. How would I write that code? |
#2
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
range("C3:c100").formula = range("C2").formula
or range("C2").autofill _ destination:=range("C2:C100") Secret Squirrel wrote: I have a formula in cell C2. I want to create a macro in VBA to fill down that formula into cells C3:C100. How would I write that code? -- Dave Peterson |
#3
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Hi Again!
Thanks for the response. After I posted this I was tinkering around with it and I got it to work using this code: Worksheet("Sheet1").Range("C2:C100").FillDown I assume it does the same thing as what you posted? "Dave Peterson" wrote: range("C3:c100").formula = range("C2").formula or range("C2").autofill _ destination:=range("C2:C100") Secret Squirrel wrote: I have a formula in cell C2. I want to create a macro in VBA to fill down that formula into cells C3:C100. How would I write that code? -- Dave Peterson |
#4
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
In this case, yep.
But .autofill has lots more options that you may find exciting <bg someday. Secret Squirrel wrote: Hi Again! Thanks for the response. After I posted this I was tinkering around with it and I got it to work using this code: Worksheet("Sheet1").Range("C2:C100").FillDown I assume it does the same thing as what you posted? "Dave Peterson" wrote: range("C3:c100").formula = range("C2").formula or range("C2").autofill _ destination:=range("C2:C100") Secret Squirrel wrote: I have a formula in cell C2. I want to create a macro in VBA to fill down that formula into cells C3:C100. How would I write that code? -- Dave Peterson -- Dave Peterson |
#5
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Ok last question... I've compiled this macro from a couple of my posts
tonight but when I fire the macro it doesn't do the filldown unless I fire it twice in a row. Any idea why that might be? The "RefreshAll" is to refresh my query I have in my workbook. Public Sub CopyTwo() ActiveWorkbook.RefreshAll Worksheets("Sheet1").Range("C2:C100").FillDown Worksheets("Sheet1").Range("A1:C100").Copy With Worksheets("Sheet2") ..Range("A1").PasteSpecial _ Paste:=xlValues, Operation:=xlNone, _ SkipBlanks:=False, Transpose:=False Application.Goto .Range("A1"), Scroll:=True End With With Worksheets("Sheet1") Application.Goto .Range("A1"), Scroll:=True End With Application.CutCopyMode = False End Sub "Dave Peterson" wrote: In this case, yep. But .autofill has lots more options that you may find exciting <bg someday. Secret Squirrel wrote: Hi Again! Thanks for the response. After I posted this I was tinkering around with it and I got it to work using this code: Worksheet("Sheet1").Range("C2:C100").FillDown I assume it does the same thing as what you posted? "Dave Peterson" wrote: range("C3:c100").formula = range("C2").formula or range("C2").autofill _ destination:=range("C2:C100") Secret Squirrel wrote: I have a formula in cell C2. I want to create a macro in VBA to fill down that formula into cells C3:C100. How would I write that code? -- Dave Peterson -- Dave Peterson |
#6
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
I don't have a query, but the rest works first time for me.
-- HTH Bob Phillips (there's no email, no snail mail, but somewhere should be gmail in my addy) "Secret Squirrel" wrote in message ... Ok last question... I've compiled this macro from a couple of my posts tonight but when I fire the macro it doesn't do the filldown unless I fire it twice in a row. Any idea why that might be? The "RefreshAll" is to refresh my query I have in my workbook. Public Sub CopyTwo() ActiveWorkbook.RefreshAll Worksheets("Sheet1").Range("C2:C100").FillDown Worksheets("Sheet1").Range("A1:C100").Copy With Worksheets("Sheet2") .Range("A1").PasteSpecial _ Paste:=xlValues, Operation:=xlNone, _ SkipBlanks:=False, Transpose:=False Application.Goto .Range("A1"), Scroll:=True End With With Worksheets("Sheet1") Application.Goto .Range("A1"), Scroll:=True End With Application.CutCopyMode = False End Sub "Dave Peterson" wrote: In this case, yep. But .autofill has lots more options that you may find exciting <bg someday. Secret Squirrel wrote: Hi Again! Thanks for the response. After I posted this I was tinkering around with it and I got it to work using this code: Worksheet("Sheet1").Range("C2:C100").FillDown I assume it does the same thing as what you posted? "Dave Peterson" wrote: range("C3:c100").formula = range("C2").formula or range("C2").autofill _ destination:=range("C2:C100") Secret Squirrel wrote: I have a formula in cell C2. I want to create a macro in VBA to fill down that formula into cells C3:C100. How would I write that code? -- Dave Peterson -- Dave Peterson |
#7
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Maybe...
Rightclick on your data|query range and select Data Range Properties. Try changing the "enable background refresh" to off. In code, something like: worksheets("Sheet1").QueryTables(1).Refresh Backgroundquery:=false If c2 is part of that querytable range, that is. Secret Squirrel wrote: Ok last question... I've compiled this macro from a couple of my posts tonight but when I fire the macro it doesn't do the filldown unless I fire it twice in a row. Any idea why that might be? The "RefreshAll" is to refresh my query I have in my workbook. Public Sub CopyTwo() ActiveWorkbook.RefreshAll Worksheets("Sheet1").Range("C2:C100").FillDown Worksheets("Sheet1").Range("A1:C100").Copy With Worksheets("Sheet2") .Range("A1").PasteSpecial _ Paste:=xlValues, Operation:=xlNone, _ SkipBlanks:=False, Transpose:=False Application.Goto .Range("A1"), Scroll:=True End With With Worksheets("Sheet1") Application.Goto .Range("A1"), Scroll:=True End With Application.CutCopyMode = False End Sub "Dave Peterson" wrote: In this case, yep. But .autofill has lots more options that you may find exciting <bg someday. Secret Squirrel wrote: Hi Again! Thanks for the response. After I posted this I was tinkering around with it and I got it to work using this code: Worksheet("Sheet1").Range("C2:C100").FillDown I assume it does the same thing as what you posted? "Dave Peterson" wrote: range("C3:c100").formula = range("C2").formula or range("C2").autofill _ destination:=range("C2:C100") Secret Squirrel wrote: I have a formula in cell C2. I want to create a macro in VBA to fill down that formula into cells C3:C100. How would I write that code? -- Dave Peterson -- Dave Peterson -- Dave Peterson |
#8
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Changing that data range property to off worked.
Thanks Dave! "Dave Peterson" wrote: Maybe... Rightclick on your data|query range and select Data Range Properties. Try changing the "enable background refresh" to off. In code, something like: worksheets("Sheet1").QueryTables(1).Refresh Backgroundquery:=false If c2 is part of that querytable range, that is. Secret Squirrel wrote: Ok last question... I've compiled this macro from a couple of my posts tonight but when I fire the macro it doesn't do the filldown unless I fire it twice in a row. Any idea why that might be? The "RefreshAll" is to refresh my query I have in my workbook. Public Sub CopyTwo() ActiveWorkbook.RefreshAll Worksheets("Sheet1").Range("C2:C100").FillDown Worksheets("Sheet1").Range("A1:C100").Copy With Worksheets("Sheet2") .Range("A1").PasteSpecial _ Paste:=xlValues, Operation:=xlNone, _ SkipBlanks:=False, Transpose:=False Application.Goto .Range("A1"), Scroll:=True End With With Worksheets("Sheet1") Application.Goto .Range("A1"), Scroll:=True End With Application.CutCopyMode = False End Sub "Dave Peterson" wrote: In this case, yep. But .autofill has lots more options that you may find exciting <bg someday. Secret Squirrel wrote: Hi Again! Thanks for the response. After I posted this I was tinkering around with it and I got it to work using this code: Worksheet("Sheet1").Range("C2:C100").FillDown I assume it does the same thing as what you posted? "Dave Peterson" wrote: range("C3:c100").formula = range("C2").formula or range("C2").autofill _ destination:=range("C2:C100") Secret Squirrel wrote: I have a formula in cell C2. I want to create a macro in VBA to fill down that formula into cells C3:C100. How would I write that code? -- Dave Peterson -- Dave Peterson -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Find value in array | Excel Worksheet Functions | |||
Reusing formula | Excel Discussion (Misc queries) | |||
Formula for current month minus one = Quarter number in a macro. | Excel Discussion (Misc queries) | |||
Formula checking multiple worksheets | Excel Worksheet Functions | |||
Macro Formula revision? | Excel Worksheet Functions |