Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
SWT SWT is offline
external usenet poster
 
Posts: 8
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default 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   Report Post  
Posted to microsoft.public.excel.programming
SWT SWT is offline
external usenet poster
 
Posts: 8
Default 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   Report Post  
Posted to microsoft.public.excel.programming
SWT SWT is offline
external usenet poster
 
Posts: 8
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
help, simple question about variables Alex[_26_] Excel Programming 6 August 9th 06 05:00 PM
general question about variables integreat Excel Discussion (Misc queries) 2 May 20th 06 07:29 AM
R: help, simple question about variables Alex[_26_] Excel Programming 0 January 22nd 05 01:16 PM
VBA question about Variables Sean Stuber Excel Programming 4 April 26th 04 03:44 PM
Question about scoping variables TBA[_2_] Excel Programming 1 January 8th 04 01:47 AM


All times are GMT +1. The time now is 01:44 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"