Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I need help with data entry

Status
Not open for further replies.

Guvnor

Technical User
Mar 26, 2002
12
GB
Say if you have got a form where you enter data for the Following deatils: Name , Age and address, how can you transfer this data to another sheet using a macro?What coding is needed?
 
Hi

This is one way to do it,

Private Sub CommandButton1_Click()

Dim myRowCount As Integer
Dim myRng As Range

Set myRng = Sheets("sheet2").Range("a:a")
myRowCount = Application.CountA(myRng)

With Sheets("sheet2")
.Cells(myRowCount + 1, 1).Value = Me.Range("a1").Value
.Cells(myRowCount + 1, 2).Value = Me.Range("b1").Value
.Cells(myRowCount + 1, 3).Value = Me.Range("c1").Value
End With

End Sub

Hope this helps.

Regards
LSTAN
 
if i want to transfer 3 values from a sheet called ' insert balance sheet' to another sheet called 'company balance sheet, what needs to be changed in this coding as it says the Me function is invalid.

Dim myRowCount As Integer
Dim myRng As Range

Set myRng = Sheets("insert balance data").Range("2:1")
myRowCount = Application.CountA(myRng)

With Sheets("company balance sheet")
.Cells(myRowCount + 10, 10).Value = .Range("a1").Value
.Cells(myRowCount + 11, 11).Value = .Range("b1").Value
.Cells(myRowCount + 12, 12).Value = .Range("c1").Value
End With

End Sub


Reagards Guvnor
 
Are you using some additional code, as the ME keyword does not seem to appear the extract you posted.

I wonder if

.Cells(myRowCount + 10, 10).Value = .Range("a1").Value

should read

.Cells(myRowCount + 10, 10).Value = MyRng.Range("a1").Value

???

A.C.
 
yes acron thats great that works qutie well. two other questions though. im using the following code:

Dim myRowCount As Integer
Dim myRng As Range

Set myRng = Sheets("insert balance data").Range("1:1")
myRowCount = Application.CountA(myRng)

With Sheets("company balance sheet")
.Cells(myRowCount + 5, 3).Value = myRng.Range("b8").Value
.Cells(myRowCount + 6, 3).Value = myRng.Range("b9").Value
.Cells(myRowCount + 8, 3).Value = myRng.Range("b11").Value
End With

End Sub

But for example instaed of the value being transeferred form cell b8 in the "insert balance sheet" to row 5 column 3 in the "company balance sheet" it is being transeferred to row6 column 3 any reason why?

Also what coding is needed to remove the value that you are transferring to another sheet form the original sheet?
 
You probably need to use :

myRowCount = Application.CountA(myRng) - 1

A.C.
 
Sweet that did the trick one final question though:

what added code is needed to remove the value that you are transferring to another sheet, from the original sheet?

Thanks for your help
 
Any ideas on the last thought of the thread?
 
could you use

MyRng.ClearContents

when finished copying ?

A.C.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top