I decided to learn VBA for Excel 2003 to relieve me of some drudgery.
These are the first few lines of a loop in a 2003 Excel VBA program I wrote:
For iChtRow=1 to nOfChtRows
For iChtCol=1 to nOfChtCols
Windows("elip4xls.txt").Activate
Worksheets("elip4xls").Activate
iCht=(iChtRow-1)*nOfChtCols+iChtCol
wsCol=iCht*2-1
If Not IsEmpty(Sheets("elip4xls").Cells(28, wsCol)) Then
Dim elipRang as Range
elipRang = Activesheet.Range(Cells(28, wsCol),Cells(92, (wsCol + 1)))
'Object variable or With block variable not set Run-time error '91' for previous line
'but the following line will work
elipRang = Worksheets("elip4xls.txt").Range(Sheets("elip4xls").Cells(28, wsCol), Sheets("elip4xls").Cells(92, (wsCol + 1)))
Charts.Add
What did I do wrong?
These are the first few lines of a loop in a 2003 Excel VBA program I wrote:
For iChtRow=1 to nOfChtRows
For iChtCol=1 to nOfChtCols
Windows("elip4xls.txt").Activate
Worksheets("elip4xls").Activate
iCht=(iChtRow-1)*nOfChtCols+iChtCol
wsCol=iCht*2-1
If Not IsEmpty(Sheets("elip4xls").Cells(28, wsCol)) Then
Dim elipRang as Range
elipRang = Activesheet.Range(Cells(28, wsCol),Cells(92, (wsCol + 1)))
'Object variable or With block variable not set Run-time error '91' for previous line
'but the following line will work
elipRang = Worksheets("elip4xls.txt").Range(Sheets("elip4xls").Cells(28, wsCol), Sheets("elip4xls").Cells(92, (wsCol + 1)))
Charts.Add
What did I do wrong?