ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Insert Record (https://www.excelbanter.com/excel-programming/438531-insert-record.html)

Sohail khan[_2_]

Insert Record
 
Sir i want to insert record one sheet cells into another sheets cells through
command button. after saving data second data will save on next row

Mike Fogleman[_2_]

Insert Record
 
Try this with Command Button on Sheet1:

Private Sub CommandButton1_Click()
Dim LRow As Long
Dim MyCell As String

LRow = Sheet2.Cells(Rows.Count, "A").End(xlUp).Row
If IsEmpty(Sheet2.Cells(LRow, 1)) Then
LRow = LRow
Else
LRow = LRow + 1
End If
MyCell = ActiveCell.Address
Sheet2.Cells(LRow, 1).Value = ActiveCell.Value
Sheet1.Range(MyCell).Activate

End Sub

Mike F
"Sohail khan" <Sohail wrote in message
...
Sir i want to insert record one sheet cells into another sheets cells
through
command button. after saving data second data will save on next row




Sohail

Insert Record
 
Mr Mike this code is not applied. I send you example

In Sheet1 there are 3 fields
A1: Invoice#
B1 DATE
C1: Qty
when I input in sheet 1 such as Invoice#: 1245, DATE: 18-1-2010, QTY:12.
Then i want these input fielsd will save in sheet2 serial wise when i click
on save button.Kindly Give me code regarding these fields



"Mike Fogleman" wrote:

Try this with Command Button on Sheet1:

Private Sub CommandButton1_Click()
Dim LRow As Long
Dim MyCell As String

LRow = Sheet2.Cells(Rows.Count, "A").End(xlUp).Row
If IsEmpty(Sheet2.Cells(LRow, 1)) Then
LRow = LRow
Else
LRow = LRow + 1
End If
MyCell = ActiveCell.Address
Sheet2.Cells(LRow, 1).Value = ActiveCell.Value
Sheet1.Range(MyCell).Activate

End Sub

Mike F
"Sohail khan" <Sohail wrote in message
...
Sir i want to insert record one sheet cells into another sheets cells
through
command button. after saving data second data will save on next row



.


Mike Fogleman[_2_]

Insert Record
 
Assuming both sheets have headers in row 1, this will transfer data from the
last used row, columns A:C of Sheet1 to the next empty row, columns A:C of
sheet2.

Private Sub CommandButton1_Click()
Dim LRow As Long
Dim Src As Range, Dest As Range

LRow = Sheet2.Cells(Rows.Count, "A").End(xlUp).Row
If IsEmpty(Sheet2.Cells(LRow, 1)) Then
LRow = LRow
Else
LRow = LRow + 1
End If
Set Dest = Sheet2.Range("A" & LRow & ":C" & LRow)
LRow = Sheet1.Cells(Rows.Count, "A").End(xlUp).Row
Set Src = Sheet1.Range("A" & LRow & ":C" & LRow)
Dest.Value = Src.Value
End Sub

Mike F

"sohail" wrote in message
...
Mr Mike this code is not applied. I send you example

In Sheet1 there are 3 fields
A1: Invoice#
B1 DATE
C1: Qty
when I input in sheet 1 such as Invoice#: 1245, DATE: 18-1-2010, QTY:12.
Then i want these input fielsd will save in sheet2 serial wise when i
click
on save button.Kindly Give me code regarding these fields



"Mike Fogleman" wrote:

Try this with Command Button on Sheet1:

Private Sub CommandButton1_Click()
Dim LRow As Long
Dim MyCell As String

LRow = Sheet2.Cells(Rows.Count, "A").End(xlUp).Row
If IsEmpty(Sheet2.Cells(LRow, 1)) Then
LRow = LRow
Else
LRow = LRow + 1
End If
MyCell = ActiveCell.Address
Sheet2.Cells(LRow, 1).Value = ActiveCell.Value
Sheet1.Range(MyCell).Activate

End Sub

Mike F
"Sohail khan" <Sohail wrote in message
...
Sir i want to insert record one sheet cells into another sheets cells
through
command button. after saving data second data will save on next row



.





All times are GMT +1. The time now is 10:30 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com