Hidden worksheet

  • Thread starter Thread starter Patrick Simonds
  • Start date Start date
P

Patrick Simonds

Why wont the following code work on a hidden worksheet? UserForm2 will be
used to place data on the hidden worksheet.


Private Sub CommandButton1_Click()
Unload UserForm3
Sheets("Engraving Jobs").Select
Range("A1").Select
UserForm2.Show
'Module3.Fill_ID_Down
End Sub
 
You can't select a hidden worksheet, but you don't need to

Private Sub CommandButton1_Click()
Unload UserForm3
UserForm2.Show
Module3.Fill_ID_Down Sheets("Engraving Jobs")
End Sub

Change the Fill_ID_Down code to accept a worksheet reference and work with
that sheet without selecting it.
 
I am afraid you lost me. I entered the code as you suggested but I get the
following error "compile error wrong number of arguments or invalid
property assignment" and when I click on debug .Fill_ID_Down Sheets (of
the line Module3.Fill_ID_Down Sheets("Engraving Jobs")) is highlighted.

You also mentioned Changing the Fill_ID_Down code to accept a worksheet
reference and work with that sheet without selecting it. Below is the Sub
Fill_ID_Down() and it does not reference the worksheet.


Sub Fill_ID_Down()
'
' Fill ID down Macro

Range("A" & Rows.Count).End(xlUp).AutoFill _
Destination:=Range("A" & Rows.Count).End(xlUp).Resize(2)

End Sub

End Sub
 
You get the error because you didn't modify Fill_ID_Down

Sub Fill_ID_Down(wks as Variant)
'
' Fill ID down Macro

With wks
.Range("A" & .Rows.Count).End(xlUp).AutoFill _
Destination:=.Range("A" & .Rows.Count).End(xlUp).Resize(2)
End with

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top