Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Using variable for cell reference | Excel Discussion (Misc queries) | |||
Variable Cell Reference | Excel Worksheet Functions | |||
Variable Cell Reference | Excel Discussion (Misc queries) | |||
problem with cell reference in =sum(offset(cell reference,x,y,z,a)). Want cell ref to be variable. | Excel Worksheet Functions | |||
Problem with =sum(offset(cell reference,w,x,y,z). I want cell reference to be variable | Excel Worksheet Functions |