Hi,
I am getting an error ""Subscript out of Range", runtime error '9' when I refer to a particular sheet in another workbook... I just change it from referring to a test sheet in the original workbook and it worked fine, but since I am referring to another workbook it's giving me errors? Anyone know why?
Here's the code... I get an error when the code goes into the first case statement...refering to another workbook "Fall03CircOrig.xls.xls"
Sub DoInsert()
Dim RowValue
RowValue = Val(UserForm007.txtRowNumber.Value)
sheetvariable = UserForm007.lblSheetLocation.Caption
Select Case sheetvariable
Case "You are on the Flax Sheet"
Windows("Fall03CircOrig.xls.xls"
.Activate
Worksheets("Flax"
.Rows(RowValue).Insert
Sheets("Flax"
.Select
Range("A" & RowValue).Select
ActiveCell.Value = sheetvariable
Case "You are on the RHO Sheet"
Windows("Fall03CircOrig.xls.xls"
.Activate
Worksheets("RHO"
.Rows(RowValue).Insert
Sheets("RHO"
.Select
Case "You are on the TShip Sheet"
Windows("Fall03CircOrig.xls.xls"
.Activate
Worksheets("TShip"
.Rows(RowValue).Insert
Sheets("TShip"
.Select
Case Else
Windows("FLX002 Fall 2003 Final Client Merge Reports Rev2.xls"
.Activate
Worksheets("Test Sheet"
.Rows(RowValue).Insert
Sheets("Test Sheet"
.Select
End Select
Range("AB" & RowValue).Select
ActiveCell.Value = v1 'adds the keycode to column AB
Range("E" & RowValue).Select
ActiveCell.Value = v1
Range("AL" & RowValue).Select
ActiveCell.Value = v3
Range("AM" & RowValue).Select
ActiveCell.Value = v4
End Sub
I am getting an error ""Subscript out of Range", runtime error '9' when I refer to a particular sheet in another workbook... I just change it from referring to a test sheet in the original workbook and it worked fine, but since I am referring to another workbook it's giving me errors? Anyone know why?
Here's the code... I get an error when the code goes into the first case statement...refering to another workbook "Fall03CircOrig.xls.xls"
Sub DoInsert()
Dim RowValue
RowValue = Val(UserForm007.txtRowNumber.Value)
sheetvariable = UserForm007.lblSheetLocation.Caption
Select Case sheetvariable
Case "You are on the Flax Sheet"
Windows("Fall03CircOrig.xls.xls"
Worksheets("Flax"
Sheets("Flax"
Range("A" & RowValue).Select
ActiveCell.Value = sheetvariable
Case "You are on the RHO Sheet"
Windows("Fall03CircOrig.xls.xls"
Worksheets("RHO"
Sheets("RHO"
Case "You are on the TShip Sheet"
Windows("Fall03CircOrig.xls.xls"
Worksheets("TShip"
Sheets("TShip"
Case Else
Windows("FLX002 Fall 2003 Final Client Merge Reports Rev2.xls"
Worksheets("Test Sheet"
Sheets("Test Sheet"
End Select
Range("AB" & RowValue).Select
ActiveCell.Value = v1 'adds the keycode to column AB
Range("E" & RowValue).Select
ActiveCell.Value = v1
Range("AL" & RowValue).Select
ActiveCell.Value = v3
Range("AM" & RowValue).Select
ActiveCell.Value = v4
End Sub