Macros | Multiple data entry and transfer data from sheet to sheet | Mimic database action

bebongtheshark

New Member
Joined
Jul 4, 2013
Messages
1
Hi everyone

I'd like to ask if it is possible to mimic actions similar to a database but only within the same workbook. If it is possible, I'd like to get a structure code for macros so that I can follow and imitate =) Here's my specs:

Here is Sheet 1

[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD][/TD]
[TD]Column A[/TD]
[TD]Column B[/TD]
[TD]Column C[/TD]
[TD]Column D[/TD]
[TD]Column E[/TD]
[/TR]
[TR]
[TD]Row 1[/TD]
[TD]Name[/TD]
[TD]Arthur McArthur Bennington (merged to Columns C and D)[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Row 2[/TD]
[TD]Age[/TD]
[TD]25 (not merged[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Row 3[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Row 4[/TD]
[TD]Ques 1[/TD]
[TD]Y[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Row 5[/TD]
[TD]Ques 2[/TD]
[TD]333.667[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Row 6[/TD]
[TD]Ques 3[/TD]
[TD]N[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Row 7[/TD]
[TD]Ques 4[/TD]
[TD](^*^&$^##^#%[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD]THERE IS SOME FORM OF SUBMIT BUTTON HERE[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]


Here is Sheet 2

[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD][/TD]
[TD]Column A[/TD]
[TD]Column B[/TD]
[TD]Column C[/TD]
[TD]Column D[/TD]
[TD]Column E[/TD]
[TD]Column F[/TD]
[TD]Column G[/TD]
[/TR]
[TR]
[TD]Row 1[/TD]
[TD]No.
[/TD]
[TD]Name
[/TD]
[TD]Age
[/TD]
[TD]Q1
[/TD]
[TD]Q2
[/TD]
[TD]Q3
[/TD]
[TD]Q4
[/TD]
[/TR]
[TR]
[TD]Row 2[/TD]
[TD]1[/TD]
[TD]Arthur McArthur Bennington[/TD]
[TD]25[/TD]
[TD]Y[/TD]
[TD]333.667[/TD]
[TD]N[/TD]
[TD](^*^&$^##^#%[/TD]
[/TR]
[TR]
[TD]Row 3[/TD]
[TD]2[/TD]
[TD]Kurt Cobain[/TD]
[TD]22[/TD]
[TD]N[/TD]
[TD]15.67[/TD]
[TD]N[/TD]
[TD]*&^()^(%$([/TD]
[/TR]
</tbody>[/TABLE]


The idea is that someone enters raw data or accomplishes Sheet 1 and presses submit button. That triggers copying of data to Sheet 2. Submit button also clears the data fields answered in Sheet 1 to enable next user to submit another set of data.

I think this is quite complex but I'm hoping someone can help me design or create an idea how to make this macro work =)

Best regards everyone! Thank you in advance for your help =D
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Create a button from the forms toolbox and attach this macro. Copy the Macro to the standard code module1. This procedure assumes that Headers in column A of sheet 1 are permanent and that headers in Row 1 of sheet 2 are permanent, both are entered and formatted prior to running the procedure. Item numbers on sheet two will be assigned automatically as items are added.

[Code}
Sub sh1Tosh2()
Dim sh1 As Worksheet, sh2 As Worksheet, lr As Long, rng As Range
Set sh1 = Sheets(1) 'Edit sheet name
Set sh2 = Sheets(2) 'Edit sheet name
lr = sh1.Cells(Rows.Count, 1).End(xlUp).Row
Set rng = sh1.Range("B2:B" & lr)
rng.Copy
sh2.Cells(Rows.Count, 2).End(xlUp)(2).PasteSpecial Transpose:=True
If Application.CountA(sh2.Range("A3:C3")) = 0 Then
sh2.Cells(Rows.Count, 1).End(xlUp)(2) = 1
Else
sh2.Cells(Rows.Count, 1).End(xlUp)(2) = sh2.Cells(Rows.Count, 1).End(xlUp).Value + 1
End If
End Sub
[/Code]
 
Upvote 0
Code:
Sub sh1Tosh2()
Dim sh1 As Worksheet, sh2 As Worksheet, lr As Long, rng As Range
Set sh1 = Sheets(1) 'Edit sheet name
Set sh2 = Sheets(2) 'Edit sheet name
lr = sh1.Cells(Rows.Count, 1).End(xlUp).Row
Set rng = sh1.Range("B2:B" & lr)
rng.Copy
sh2.Cells(Rows.Count, 2).End(xlUp)(2).PasteSpecial Transpose:=True
    If Application.CountA(sh2.Range("A3:C3")) = 0 Then
        sh2.Cells(Rows.Count, 1).End(xlUp)(2) = 1
    Else
        sh2.Cells(Rows.Count, 1).End(xlUp)(2) = sh2.Cells(Rows.Count, 1).End(xlUp).Value + 1
    End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,098
Messages
6,170,103
Members
452,302
Latest member
TaMere

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