Can anyone help me with an excel vba userform issue im having?
I’m trying to copy and paste data in a cell from one worksheet to another, but when I try to paste the data into the second worksheet, it pastes it into the same cell, but on the first worksheet??
Im launching a userform via a macro on the first worksheet, called “Risk Assessment”. This switches over to the second worksheet, called “Hazard Selector”, and loads my userform.
Heres the code for that macro, assigned to a button in the “risk assessment” worksheet.
Sub HazardWizard()
Sheets("Hazard Selector").Select
UserForm2.Show
End Sub
I then use the form to make some selections in the “Hazard Selector” sheet, which put data into cell D11 on the “Hazard Selector” sheet.
Using a button on the userform I then want to copy this D11 data, switch back to the “Risk Assessment” worksheet and close the userform. Im using this code to do this, assigned to a button on the Userform.
Private Sub CommandButton1_Click()
Range("D11").Copy
Sheets("Risk Assessment").Select
Unload Me
End Sub
This seems to work, and I have the contents of cell D11 on my clipboard, however, when I now try and paste this data into my “Risk Assessment” worksheet, for example into cell A1- nothing happens.
Instead, the contents paste into the “Hazard Selector” worksheet instead, into cell A1?!
I cant for the life of me figure out why, can anyone help?!
Many thanks