Foo_Man_Chu
Board Regular
- Joined
- Jul 22, 2010
- Messages
- 79
I have a spreadsheet where the following code runs after a button is clicked. The code is supposed to ultimately update another spreadsheet from the current spreadsheet. When it runs it gives me a subscript out of range error on this line :
I've looked around and from what I've seen this is either due to trying to reference an element outside the bounds of an array or trying to refer to something that isn't in the spreadsheet. There is no array involved and the only two values are "Esc-Gum-LD" and the variable "file". I checked and the workbook "file" represents exists and is open and it contains a sheet named "Esc-Gum-LD". Please, can someone help me?
Here is my code:
Code:
Workbooks(file).Worksheets("Esc-Gum-LD").Range(F29) = "c"
I've looked around and from what I've seen this is either due to trying to reference an element outside the bounds of an array or trying to refer to something that isn't in the spreadsheet. There is no array involved and the only two values are "Esc-Gum-LD" and the variable "file". I checked and the workbook "file" represents exists and is open and it contains a sheet named "Esc-Gum-LD". Please, can someone help me?
Here is my code:
Code:
Private Sub updateTargetSpreadsheet(Optional ByVal strAddr As String, Optional ByVal strColRow As String, Optional ByVal strColor As String, Optional ByVal strType As String)
Dim file As String
Dim strLDAddr As String
Dim strESCAddr As String
Dim blnLoadDock As Boolean
blnLoadDock = False
file = Format(Date, "m.d.yy.x\l\sx")
If strType = "Cell" Then
If strAddr = "$D$3" Then
strLDAddr = "B" & strColRow
End If
If strColor = "64636" Then
If Not strLDAddr = vbNullString Then
Workbooks(file).Worksheets("Esc-Gum-LD").Range(F29) = "c"
Workbooks(file).Worksheets("Esc-Gum-LD").Range(strLDAddr).Offset(0, 1) = "h"
ElseIf Not strESCAddr = vbNullString Then
Workbooks(file).Worksheets("Esc-Gum-LD").Range(strESCAddr) = "o"
End If
Else
If Not strLDAddr = vbNullString Then
Workbooks(file).Worksheets("Esc-Gum-LD").Range(strLDAddr) = "o"
Workbooks(file).Worksheets("Esc-Gum-LD").Range(strLDAddr).Offset(0, 1) = "h"
ElseIf Not strESCAddr = vbNullString Then
Workbooks(file).Worksheets("Esc-Gum-LD").Range(strESCAddr) = "x"
End If
End If
.......