Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Subscript out of range (Error 9)

Status
Not open for further replies.

zollo9999

Programmer
May 12, 2002
95
0
0
AU
Hi

This follows on from a previous post and shows my ignorance of XL-VBA objects.

thread707-690573

What is out of range in the code below ???
Debug shows the string strWkShtDatafile has the correct string value for the sheetname ie "Svcs-Master".
and the strX has the value "A2"


For intRowNbr = intRowStart To intRowEnd

strRowNbr = Format(intRowNbr, "#")
strX = strColProgramCode & strRowNbr

strValProgramCode = Sheets(strWkShtDatafile).Range(strX).Value


' Other code omitted

Next intRowNbr


Any Ideas?

I have also tried

strRowNbr = Format(intRowNbr, "0")

but it makes no difference.

I'm just trying to get values from one wkbk and put them in another. I also want to use the values in a SaveCopyAs so I cant do a simple copy & paste between cells. I need to concatenate string values from 3 cells in the datasheet.

Another Error I may have made this that
strValProgramCode is a string but the value in the cell is a number. I will try again changing the variable to a different data type.

Zollo9999 A+
(Very Part-Time Programmer)
[thumbsup]
 
*****************************
No need to reply to this thread.
*****************************

I've figured out the correct reference for my problem:

An guide to referencing the value is:
String Value = WorkbookName.Worksheets("Worksheetname").Range("Range").Value

The specific example in my code is:

strValProgramCode = wkbDatafile.Worksheets(strWkShtDatafile) _
.Range(strColProgramCode & strRowNbr).Value


Thanks anyway

I now have another problem.
If I can figure it out I'll "call" again for help.

regards

Zollo9999 A+
(Very Part-Time Programmer)
[thumbsup]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top