Automated Data Add Row by Row

Zaw Ye Aung

New Member
Joined
Oct 19, 2023
Messages
2
Office Version
  1. 365
Platform
  1. Windows
I would like to add data row by row in a single data entry sheet.

When I click a button, the data should be automatically added to the data entry sheet.

When I click the button again, the new data should be added one row below the previous entry.

However, I want to reference only one row. For example, I will fill in data in the reference row (1:1), then click the button, and the data should be added to the data entry sheet.

After that, I may re-edit the data in the reference row (1:1) and click the button again. At that time, the data should automatically fill in the second row.


VBA Code:
Excel Formula:
 

Attachments

  • 2023-10-19 14_31_14-Mini Sheet - Excel.png
    2023-10-19 14_31_14-Mini Sheet - Excel.png
    13 KB · Views: 9
  • Capture.JPG
    Capture.JPG
    36.7 KB · Views: 9

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Sheet 1 = Data Entry
Sheet 2 = Master Sheet

Try this Code


VBA Code:
Sub CopyAndInsertData()
    Dim wsDataEntry As Worksheet
    Dim wsMaster As Worksheet
    Dim lastRow As Long
   
    ' Set references to the worksheets
    Set wsDataEntry = ThisWorkbook.Sheets("Data Entry")
    Set wsMaster = ThisWorkbook.Sheets("Master Sheet")
   
    ' Find the last used row in the Master Sheet
    lastRow = wsMaster.Cells(wsMaster.Rows.Count, "A").End(xlUp).Row
   
    ' Insert a new row at the top of the Master Sheet
    wsMaster.Rows("2:2").Insert Shift:=xlDown
   
    ' Copy data from Data Entry to Master Sheet A1:D1
    wsDataEntry.Range("A1:D1").Copy wsMaster.Range("A2")
End Sub

You can change range according to your data
 
Upvote 0
Sheet 1 = Data Entry
Sheet 2 = Master Sheet

Try this Code


VBA Code:
Sub CopyAndInsertData()
    Dim wsDataEntry As Worksheet
    Dim wsMaster As Worksheet
    Dim lastRow As Long
  
    ' Set references to the worksheets
    Set wsDataEntry = ThisWorkbook.Sheets("Data Entry")
    Set wsMaster = ThisWorkbook.Sheets("Master Sheet")
  
    ' Find the last used row in the Master Sheet
    lastRow = wsMaster.Cells(wsMaster.Rows.Count, "A").End(xlUp).Row
  
    ' Insert a new row at the top of the Master Sheet
    wsMaster.Rows("2:2").Insert Shift:=xlDown
  
    ' Copy data from Data Entry to Master Sheet A1:D1
    wsDataEntry.Range("A1:D1").Copy wsMaster.Range("A2")
End Sub

You can change range according to your data
Thanks!!!
Can we add button click at Master sheet???
if you can support it, please help to support bro!
 
Upvote 0

Forum statistics

Threads
1,215,108
Messages
6,123,132
Members
449,098
Latest member
Doanvanhieu

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