ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VBE syntax line question (https://www.excelbanter.com/excel-programming/282690-vbe-syntax-line-question.html)

Colette

VBE syntax line question
 
How do I write the syntax in my macro using VBE to
perform this:
I need to create a variable named "OldStock" and set it
equal to the value of cell H2

Any help would be great. thanks

RADO[_3_]

VBE syntax line question
 
Dim OldStock

OldStock=Cells("H2").Value

Best,

RADO

"Colette" wrote in message
...
How do I write the syntax in my macro using VBE to
perform this:
I need to create a variable named "OldStock" and set it
equal to the value of cell H2

Any help would be great. thanks




Bob Phillips[_6_]

VBE syntax line question
 
RADO,

I don't think you can use Cells in this way. You could use

OldStock = Cells(2,"H").Value

or

OldStock = Cells(2, ,8).Value

or

OldStock = Range("H2").Value

or even

OldSTock = Range("A1").Cells(2,"H").Value

or variations on the same, but not Cells("H2").


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"RADO" wrote in message
...
Dim OldStock

OldStock=Cells("H2").Value

Best,

RADO

"Colette" wrote in message
...
How do I write the syntax in my macro using VBE to
perform this:
I need to create a variable named "OldStock" and set it
equal to the value of cell H2

Any help would be great. thanks






RADO[_3_]

VBE syntax line question
 
Oops. Thanks, Bob - I meant Range("H2")... Sorry.. programmed all night
long, can't think straight.
Best -

RADO


"Bob Phillips" wrote in message
...
RADO,

I don't think you can use Cells in this way. You could use

OldStock = Cells(2,"H").Value

or

OldStock = Cells(2, ,8).Value

or

OldStock = Range("H2").Value

or even

OldSTock = Range("A1").Cells(2,"H").Value

or variations on the same, but not Cells("H2").


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"RADO" wrote in message
...
Dim OldStock

OldStock=Cells("H2").Value

Best,

RADO

"Colette" wrote in message
...
How do I write the syntax in my macro using VBE to
perform this:
I need to create a variable named "OldStock" and set it
equal to the value of cell H2

Any help would be great. thanks









All times are GMT +1. The time now is 08:13 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com