VBA
Discuss AutoCAD ActiveX and VBA (Visual Basic for Applications) questions here.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

set a different worksheet current ?

1 REPLY 1
Reply
Message 1 of 2
mdhutchinson
124 Views, 1 Reply

set a different worksheet current ?

How do I set a different worksheet current.
I tried changing the item number on this line...
<<< Set shtObj = excelApp.Worksheet(1) >>>
but it didn't work...?

Private Sub CommandButton1_Click()
Dim excelApp As Excel.Application
Dim wbkObj As Workbook
Dim shtObj As Worksheet
On Error Resume Next
UserForm1.Hide
Err.Clear
Set excelApp = GetObject(, "Excel.Application")
If Err <> 0 Then
Err.Clear
Set excelApp = CreateObject("Excel.Application")
If Err <> 0 Then
MsgBox "Could not start excel", vbExclamation
End
End If
End If
excelApp.Visible = True
Set wbkObj = excelApp.Workbooks.Add
Set shtObj = excelApp.Worksheet(1)
UserForm1.Show
End Sub
1 REPLY 1
Message 2 of 2
joesu
in reply to: mdhutchinson

I believe this should do it.

Joe
--

Worksheets("Sheet2").Activate

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost