Dim an userform and then setting as an object

rlink_23

Board Regular
Joined
Oct 30, 2015
Messages
149
So I re-thought my Userform data transfer to the worksheet. I previously had a workbook that would save my "quotes" and move all the info over to the register and would change the quote number as it was saved. It would count up by one on "Quote" worksheet so the every time the worksheet saved and the register would move to the next line. What I would like to do have the same coding to work with the Userform. I want the Userform to save and transfer over to the register, and wanted Column A to be a hyperlink so if clicked it would take the counterman to directly to "Sales" sheet.. This is what I have so far but I don't know how to set the Userform like I would a worksheet... I read that you set it as an object but I can't figure out how to do that.. This is the code I have so far and it errors out on the "set ws1 = ?. I have not made it to the hyperlink to know if that works.. Hopefully someone knows how to do this..


Code:
Private Sub CommandButton5_Click()  Dim ws1 As Object
  Dim ws2 As Worksheet
  Set ws1 = UserForm 
  Set ws2 = Worksheets("Quotes")
  
 nextrow = ws2.Cells(Rows.Count, 1).End(xlUp).Row + 1
     
      ws2.Cells(nextrow, 1).Resize(1, 16).Value = Array(ws1.Range("QuoteNumber"), ws1.Range("Date1"), ws1.Range("Year" + " " + "Make" + " " + "Model"), ws1.Range("size"), ws1.Range("ComboBox1"), ws1.Range("Cost"), ws1.Range("custNumber"), ws1.Range("Company"), ws1.Range("FirstName" + " " + "LastName"), ws1.Range("phone1"), ws1.Range("City"), ws1.Range("State"), ws1.Range("ZipCode"), ws1.Range("email"), ws1.Range("Initals"))
      
With ws2
   .Hyperlinks.Add Anchor:=.Range("A" & nextrow), Address:=Sheets("Sales")
   End With
   
      End Sub
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.

Forum statistics

Threads
1,224,827
Messages
6,181,200
Members
453,022
Latest member
RobertV1609

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top