Transfer Userform Data into Sheet new row every time

Amature Excel Guru

New Member
Joined
Oct 14, 2022
Messages
3
Office Version
  1. 2021
Platform
  1. Windows
Hello Gurus,

I am new to this portal and hoping you to help me in the VBA.

I have created a multilayer user form for my organization. User form contains multiple combo box, textbox, and checkbox. I have assign a macro to submit button at the end so once that is hit, it will automatically capture all the data into the worksheet ("sheet3").

Only issue i am seeing with the code is that every time it goes to first row and overwrites the data instead of going into the next row. The code reads as below:

1665753429626.png




1665753461134.png



Not sure what is wrong here
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Hi,
welcome to forum

you have your LastRow variable intialized to an unqualified range so unless the worksheet data is being posted to is the activesheet, you will not get desired result

try update to your code below & see if helps

VBA Code:
Sub Submit()
    Dim sh      As Worksheet
    Dim LastRow As Long
   
    Set sh = ThisWorkbook.Worksheets("Sheet3")
   
    LastRow = sh.Cells(sh.Rows.Count, "B").End(xlUp).Row + 1
   
    'rest of code
End Sub

also when posting code, use code tags MenuBar > VBA & place code between the tags

Dave
 
Upvote 0
Solution
Hi,
welcome to forum

you have your LastRow variable intialized to an unqualified range so unless the worksheet data is being posted to is the activesheet, you will not get desired result

try update to your code below & see if helps

VBA Code:
Sub Submit()
    Dim sh      As Worksheet
    Dim LastRow As Long
  
    Set sh = ThisWorkbook.Worksheets("Sheet3")
  
    LastRow = sh.Cells(sh.Rows.Count, "B").End(xlUp).Row + 1
  
    'rest of code
End Sub

also when posting code, use code tags MenuBar > VBA & place code between the tags

Dave
It worked perfectly. Thank you so much for the help
 
Upvote 0
Can someone help me with the code which i can use to save the excel data from one file to another excel file at different location
 
Upvote 0

Forum statistics

Threads
1,215,622
Messages
6,125,886
Members
449,269
Latest member
GBCOACW

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