Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 14
Default Using variable for cell reference

how can I use variable for cell reference. IF i want to refere G9
cell and my variable mRow have value 9 how can use in excel macro
coding
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 793
Default Using variable for cell reference

instead of using "G9" use "G" & mRow

eg
Range("G9") can be replaced by Range("G" & mRow)

Sub t()
MsgBox "Direct reference: G9=" & Range("G9")
mRow = 9
MsgBox "Indirect reference: G9= " & Range("G" & mRow)
End Sub

"bmurlidhar" wrote:

how can I use variable for cell reference. IF i want to refere G9
cell and my variable mRow have value 9 how can use in excel macro
coding

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 14
Default Using variable for cell reference

On Jul 17, 9:14*am, Sheeloo wrote:
instead of using "G9" use "G" & mRow

eg
Range("G9") can be replaced by Range("G" & mRow)

Sub t()
MsgBox "Direct reference: G9=" & Range("G9")
mRow = 9
MsgBox "Indirect reference: G9= " & Range("G" & mRow)
End Sub

"bmurlidhar" wrote:
how can I use variable for cell reference. IF i want to *refere G9
cell and *my variable mRow have value 9 how can use in excel macro
coding


I want to give sum command i.e. =SUM(H1:H10) and my variable for
mFrow = 1 and mLrow = 10 how can i use variable in function
  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 793
Default Using variable for cell reference

you need to prepare the string H1:H10 using & operator to concatenate your
variables

share the line of code where you want to use the variables so that we can
tell you exactly what you want.

"bmurlidhar" wrote:

On Jul 17, 9:14 am, Sheeloo wrote:
instead of using "G9" use "G" & mRow

eg
Range("G9") can be replaced by Range("G" & mRow)

Sub t()
MsgBox "Direct reference: G9=" & Range("G9")
mRow = 9
MsgBox "Indirect reference: G9= " & Range("G" & mRow)
End Sub

"bmurlidhar" wrote:
how can I use variable for cell reference. IF i want to refere G9
cell and my variable mRow have value 9 how can use in excel macro
coding


I want to give sum command i.e. =SUM(H1:H10) and my variable for
mFrow = 1 and mLrow = 10 how can i use variable in function

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
cell reference as variable? Ruthie Excel Discussion (Misc queries) 17 April 26th 10 02:39 AM
Variable Cell Reference Andrew Excel Discussion (Misc queries) 3 December 29th 06 03:35 PM
How do I use a variable in a cell reference? BraveFencerPawson Excel Discussion (Misc queries) 1 April 1st 05 06:35 PM
problem with cell reference in =sum(offset(cell reference,x,y,z,a)). Want cell ref to be variable. [email protected] Excel Worksheet Functions 2 December 11th 04 12:05 AM
Problem with =sum(offset(cell reference,w,x,y,z). I want cell reference to be variable [email protected] Excel Worksheet Functions 2 December 11th 04 12:00 AM


All times are GMT +1. The time now is 11:33 PM.

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"