Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
SJW SJW is offline
external usenet poster
 
Posts: 5
Default Reference Cell # with variable

Need help with the code below.
If I substitute
CellContents = Worksheets("Data for Sim RT").[B100].Text
It works!

Sub TestCellVariable()
Dim CellContents As Variant '...Cell contents
Dim lngCellNum As Long '...Row number
Dim strCell As Variant

lngCellNum = 100

strCell = "B" & lngCellNum
CellContents = Worksheets("Data for Sim RT").[strCell].Text

MsgBox "zzz Cell Contents is " & CellContents

End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,440
Default Reference Cell # with variable

CellContents = Worksheets("Data for Sim RT").Range(strCell).Text

--
Kind regards,

Niek Otten
Microsoft MVP - Excel

"sjw" wrote in message ...
| Need help with the code below.
| If I substitute
| CellContents = Worksheets("Data for Sim RT").[B100].Text
| It works!
|
| Sub TestCellVariable()
| Dim CellContents As Variant '...Cell contents
| Dim lngCellNum As Long '...Row number
| Dim strCell As Variant
|
| lngCellNum = 100
|
| strCell = "B" & lngCellNum
| CellContents = Worksheets("Data for Sim RT").[strCell].Text
|
| MsgBox "zzz Cell Contents is " & CellContents
|
| End Sub


  #3   Report Post  
Posted to microsoft.public.excel.programming
SJW SJW is offline
external usenet poster
 
Posts: 5
Default Reference Cell # with variable

Perfect!

Thanks,
sjw

"Niek Otten" wrote:

CellContents = Worksheets("Data for Sim RT").Range(strCell).Text

--
Kind regards,

Niek Otten
Microsoft MVP - Excel

"sjw" wrote in message ...
| Need help with the code below.
| If I substitute
| CellContents = Worksheets("Data for Sim RT").[B100].Text
| It works!
|
| Sub TestCellVariable()
| Dim CellContents As Variant '...Cell contents
| Dim lngCellNum As Long '...Row number
| Dim strCell As Variant
|
| lngCellNum = 100
|
| strCell = "B" & lngCellNum
| CellContents = Worksheets("Data for Sim RT").[strCell].Text
|
| MsgBox "zzz Cell Contents is " & CellContents
|
| End Sub



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
Using variable for cell reference bmurlidhar Excel Discussion (Misc queries) 3 July 17th 09 07:16 AM
Variable Cell Reference Stormy Excel Worksheet Functions 2 February 15th 09 04:00 PM
Variable Cell Reference Andrew Excel Discussion (Misc queries) 3 December 29th 06 03: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 10:51 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"