Transfer data from sheet1 to sheet 2 using VBA

Jo4x4

Board Regular
Joined
Jan 8, 2011
Messages
136
Hi everybody,
I have a very simple workbook with the following: On sheet1, there are four "inputs", three of them lists, and the fourth is a name field.

When the data is captured via a button, I want the data to appear on sheet2 in the next available row. However, it should put it under the correct column, depending on input 3 on sheet 1.

As the html maker is currently unavailable, I cannot ad samples.

Any help would be appreciated.

Thanks
Jo
Win XP, Excel 2010
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Hi Jo, your query was not very clear, howerver try something like this,

Code:
Sub MyMacro()
input1 = Sheet1.Cells(6, 4).Value
input2 = Sheet1.Cells(7, 4).Value
input3 = Sheet1.Cells(8, 4).Value
input4 = Sheet1.Cells(9, 4).Value
Sheet2.Activate
'Assuming that the data input3 is the column index
For i = 1 To 500
    If Sheet2.Cells(i, input3).Value = "" Then
 
        Sheet2.Cells(i, input3).Value = input1
        Sheet2.Cells(i + 1, input3).Value = input2
        Sheet2.Cells(i + 2, input3).Value = input3
        Sheet2.Cells(i + 3, input3).Value = input4
        Exit For
        
    End If
Next
End Sub

Thanks,

Ogo
 
Upvote 0

Forum statistics

Threads
1,224,586
Messages
6,179,730
Members
452,939
Latest member
WCrawford

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