Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Simple VBA - What's wrong??


Here's my sub-procedure, I am getting the error
message "Subscript out of range". Please help, I am only
wanting to set the cells value to a variable.

Public Sub TEST()
Dim strCellTest As String

sCellTest = Worksheets("Sheet1").Cells(1, 1).Value
Debug.Print sCellTest

End Sub

Also, how do I SET a cells value? Like this?:

Worksheets("Sheet1").Cells(1, 1).Value = strNewVal

Thanks in advance,

ChrisB

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Simple VBA - What's wrong??

Chris,

Are you sure you have a worksheet named "Sheet1"?


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"ChrisB" wrote in message
...

Here's my sub-procedure, I am getting the error
message "Subscript out of range". Please help, I am only
wanting to set the cells value to a variable.

Public Sub TEST()
Dim strCellTest As String

sCellTest = Worksheets("Sheet1").Cells(1, 1).Value
Debug.Print sCellTest

End Sub

Also, how do I SET a cells value? Like this?:

Worksheets("Sheet1").Cells(1, 1).Value = strNewVal

Thanks in advance,

ChrisB



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Simple VBA - What's wrong??


"ChrisB" schreef in bericht
...

Here's my sub-procedure, I am getting the error
message "Subscript out of range". Please help, I am only
wanting to set the cells value to a variable.

Public Sub TEST()
Dim strCellTest As String

sCellTest = Worksheets("Sheet1").Cells(1, 1).Value
Debug.Print sCellTest

End Sub

Also, how do I SET a cells value? Like this?:

Worksheets("Sheet1").Cells(1, 1).Value = strNewVal

Thanks in advance,

ChrisB


Are you sure Sheet1exist????????


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Simple VBA - What's wrong??

Chris,

Do you have worksheet called Sheet1?

By the way, you dimension a variable called strCellTest, and then use
sCellTest. Precede your code with Option Explicit!

--

HTH

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

"ChrisB" wrote in message
...

Here's my sub-procedure, I am getting the error
message "Subscript out of range". Please help, I am only
wanting to set the cells value to a variable.

Public Sub TEST()
Dim strCellTest As String

sCellTest = Worksheets("Sheet1").Cells(1, 1).Value
Debug.Print sCellTest

End Sub

Also, how do I SET a cells value? Like this?:

Worksheets("Sheet1").Cells(1, 1).Value = strNewVal

Thanks in advance,

ChrisB



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
Simple multiplication of 2 cells = wrong product chrisp Excel Discussion (Misc queries) 9 April 28th 23 11:44 AM
What is wrong with this simple formula? Jack B Excel Discussion (Misc queries) 4 October 14th 09 04:34 PM
Insert Calculated Field (wrong Qty*Price = wrong Amount) Edmund Excel Discussion (Misc queries) 8 October 4th 07 12:13 PM
Simple SUMIF formula gone wrong! exutable Excel Worksheet Functions 6 May 8th 06 11:58 AM
Help! What's wrong with this simple copy and paste Richard James[_3_] Excel Programming 4 November 23rd 03 12:57 AM


All times are GMT +1. The time now is 10:03 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"