USERFORM fill out and transer data to new sheet

Patriot2879

Well-known Member
Joined
Feb 1, 2018
Messages
1,227
Office Version
  1. 2010
Platform
  1. Windows
Hi really helping you can help me with the code below please, i have a userform which i can fill out, when i click the ok button i want the information entered to be transferred into sheet6 in columns a - d then every time new info is added to goto a new lane, but i keep getting erros pop up please can you help again, i am very new to all this so still learning, and any advise you can give will be very much appreciated :)

Code:
Private Sub OKButton_Click()

Dim emptyRow As Long

'Make Sheet1 active
Sheet1.Activate

'Determine emptyRow
emptyRow = ThisWorkbook.Sheets("Sheet6").CountA(Range("A:D")) + 1

'Transfer information
Cells(emptyRow, 1).Value = DateBox.Value
Cells(emptyRow, 2).Value = MPANBox.Value
Cells(emptyRow, 3).Value = ManagerBox.Value
Cells(emptyRow, 4).Value = NotesBox.Value


End Sub
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
What errors are you getting & on what line?
Also what is the name of the sheet you want to write the data to?
 
Upvote 0
HI thanks for getting back to me, i am getting Run-Time error '13': Type mismatch error which when i click on debug it highlights emptyRow = ThisWorkbook.Sheets("Sheet6").Range("A:D") + 1,
i want to get the data from UserForm2 which i have an OK button on so when i click then the data is transferred to sheet6 :)
 
Upvote 0
Ok, try this
Code:
Private Sub OKButton_Click()

Dim emptyRow As Long

'Make Sheet1 active
'Sheet1.Activate

'Determine emptyRow
With ThisWorkbook.Sheets("Sheet6")
   emptyRow = .Range("A:D").Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row

   'Transfer Information
   .Cells(emptyRow, 1).Value = DateBox.Value
   .Cells(emptyRow, 2).Value = MPANBox.Value
   .Cells(emptyRow, 3).Value = ManagerBox.Value
   .Cells(emptyRow, 4).Value = NotesBox.Value
End With

End Sub
 
Upvote 0
this is great thankyou but how do i get it to add a new line automaticall please
 
Upvote 0
Sorry, my mistake. Change this line as shown
Code:
 emptyRow = .Range("A:D").Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row [COLOR=#ff0000]+1[/COLOR]
 
Upvote 0
Sorry me again please can you advise when the data is copied and transferred into sheet6 how do i start it from A@:D2 to be copied into? thank you again for your time.
 
Upvote 0
Glad to help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,213,568
Messages
6,114,348
Members
448,570
Latest member
rik81h

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