Worksheet name
Hi Anthony,
I assumed that txtWorksheet was a TextBox and,
in such case, using the suggested code, I was
unable to reproduce your error.
Could there be something wrong with the declaration I made?
Post the code which you used
---
Regards,
Norman
"Anthony" wrote in message
...
Hi Norman,
Thanks. I tried but when I run to the below line, I get a "type mismatch"
error.
Set ws = ActiveWorkbook.Sheets(txtWorksheet.Text)
Could there be something wrong with the declaration I made?
Thanks & Regards
Anthony
"Norman Jones" wrote:
Hi Anthony,
Try something like:
'=============
Private Sub cmdUpdate_Click()
Dim fname As String, ws1 As String
Dim ws As Worksheet
fname = txtFileName.Text
Workbooks.Open fname
On Error Resume Next
Set ws = ActiveWorkbook.Sheets(txtWorksheet.Text)
If ws Is Nothing Then
MsgBox "Please input name of Worksheet"
End If
On Error GoTo 0
If Not ws Is Nothing Then
Call Module1.CopyPrice(ws, 4)
End If
End Sub
'<<=============
---
Regards,
Norman
"Anthony" wrote in message
...
Hi,
Hope someone can help.
I created a form and has a text box in it. User key in the name of the
worksheet in the text box but I stumble upon a compile error. My code
is
as
below
Private Sub cmdUpdate_Click()
Dim fname, ws1 As String
Dim ws As Worksheet
fname = txtFileName
Workbooks.Open fname
Set ws = txtWorksheet
If ws = "" Then
MsgBox "Please input name of Worksheet"
End If
Call Module1.CopyPrice(ws, 4)
End Sub
|