flyfisher15
04-12-2012, 06:40 AM
I'm trying to determine the value in a cell, and pull that value which in this case would be "ENV 4246". I clean out the space and then try to call a sub which has the same name as the text in the cell. Whenever I try to call that sub though it tells me that "ENV4246" cannot run because it's not available.
Code is below
Any help would be greatly appreciated!
Option Explicit
Option Compare Binary
Option Base 0
Public Sub main_comments()
Dim Z
Dim Cell As Range
Dim strsubname As String
Dim testy As Range
Dim cellval
cellval = 3
Z = 3
While Range("B" & Z) <> ""
Z = Z + 1
Wend
Z = Z - 1
For Each Cell In Range("B3:B" & Z)
strsubname = Cell.Value
strsubname = Replace(strsubname, " ", "")
cellval = cellval + 1
Run strsubname
Next
End Sub
__________________________________________________________________
'Setting this to True will turn off all error handling:
#Const m_blnErrorHandlersOff_c = True
Public Sub ENV4246()
If Range("B" & cellval).Value = "ENV 4246" Then
If InsertPictureComment(ActiveSheet.Range("B3"), "M:\Fulfillment_Ops\INVENTORY\Statement Images - 4-10\ENV 4246_20100101_0.jpg", _
overWrite:=True) Then
Else
MsgBox "Could not insert picture."
End If
End If
End Sub
Code is below
Any help would be greatly appreciated!
Option Explicit
Option Compare Binary
Option Base 0
Public Sub main_comments()
Dim Z
Dim Cell As Range
Dim strsubname As String
Dim testy As Range
Dim cellval
cellval = 3
Z = 3
While Range("B" & Z) <> ""
Z = Z + 1
Wend
Z = Z - 1
For Each Cell In Range("B3:B" & Z)
strsubname = Cell.Value
strsubname = Replace(strsubname, " ", "")
cellval = cellval + 1
Run strsubname
Next
End Sub
__________________________________________________________________
'Setting this to True will turn off all error handling:
#Const m_blnErrorHandlersOff_c = True
Public Sub ENV4246()
If Range("B" & cellval).Value = "ENV 4246" Then
If InsertPictureComment(ActiveSheet.Range("B3"), "M:\Fulfillment_Ops\INVENTORY\Statement Images - 4-10\ENV 4246_20100101_0.jpg", _
overWrite:=True) Then
Else
MsgBox "Could not insert picture."
End If
End If
End Sub