Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA question concerning variables
Can Visual Basic get information from a cell and then use that as a
variable? I have a cell that changes using the function counta. The number in the Counta formula will change from day to day. I would like to use that number as a variable in a macro. Does anyone have any VBA code that shows how this could be done? SWT |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA question concerning variables
myVar = Range("B2").Value as an example -- HTH RP (remove nothere from the email address if mailing direct) "SWT" wrote in message oups.com... Can Visual Basic get information from a cell and then use that as a variable? I have a cell that changes using the function counta. The number in the Counta formula will change from day to day. I would like to use that number as a variable in a macro. Does anyone have any VBA code that shows how this could be done? SWT |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA question concerning variables
Well, you could use something like
x = worksheetfunction.counta(range("b2:b116")) and x would be the variable with the changing data. "SWT" wrote: Can Visual Basic get information from a cell and then use that as a variable? I have a cell that changes using the function counta. The number in the Counta formula will change from day to day. I would like to use that number as a variable in a macro. Does anyone have any VBA code that shows how this could be done? SWT |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA question concerning variables
Thanks all,
this is the final macro written which works exactly as i hoped. Sub QB_Format() ' ' QB_Format Macro ' Macro recorded 10/19/2005 by SWT ' Copies rows 4 through 6 and pastes to varying rows x = Range("Count").Value sRange = "A7:K" & x Range("A4:K6").Copy Destination:=Range(sRange) End Sub SWT |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA question concerning variables
I revised it and found that this also worked: I eliminated having to
have a counta function in the sheet: Sub QB_Format() ' ' QB_Format Macro ' Macro recorded 10/19/2005 by SWT ' Copies rows 4 through 6 and pastes to varying rows R = WorksheetFunction.CountA(Range("M_Amount")) S = (R * 3) + 3 sRange = "A7:K" & S Range("A4:K6").Copy Destination:=Range(sRange) |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
help, simple question about variables | Excel Programming | |||
general question about variables | Excel Discussion (Misc queries) | |||
R: help, simple question about variables | Excel Programming | |||
VBA question about Variables | Excel Programming | |||
Question about scoping variables | Excel Programming |