Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
I am trying to get a script to work that will copy data from one sheet of a workbook to the next free row of a different sheet in the same workbook. What i want to do is increment the value of "x" in the first line below each time the script is used: Dim x As Long x = Application.WorksheetFunction.CountA(Range("A:A")) + 2 Worksheets("Sheet 1").Cells(x, 2).Value = Worksheets("Sheet 2").Cells(1, 46).Value Worksheets("Sheet 1").Cells(x, 3).Value = Worksheets("Sheet 2").Cells(2, 46).Value i.e First time script is run: x = Application.WorksheetFunction.CountA(Range("A:A")) + 2 Next time script is run: x = Application.WorksheetFunction.CountA(Range("A:A")) + 3 etc. Any help/advice/suggestions would be much appreciated. -- Cheers Peter Remove the INVALID to reply |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Peter,
Try this Static x As Long If x = 0 Then x = 2 With Worksheets("Sheet 1") x = Application.WorksheetFunction.CountA(Range("A:A")) .Cells(x, 2).Value = Worksheets("Sheet2").Cells(1, 46).Value .Cells(x, 3).Value = Worksheets("Sheet2").Cells(2, 46).Value End With x = x + 1 -- HTH RP (remove nothere from the email address if mailing direct) "Peter" wrote in message ... Hi, I am trying to get a script to work that will copy data from one sheet of a workbook to the next free row of a different sheet in the same workbook. What i want to do is increment the value of "x" in the first line below each time the script is used: Dim x As Long x = Application.WorksheetFunction.CountA(Range("A:A")) + 2 Worksheets("Sheet 1").Cells(x, 2).Value = Worksheets("Sheet 2").Cells(1, 46).Value Worksheets("Sheet 1").Cells(x, 3).Value = Worksheets("Sheet 2").Cells(2, 46).Value i.e First time script is run: x = Application.WorksheetFunction.CountA(Range("A:A")) + 2 Next time script is run: x = Application.WorksheetFunction.CountA(Range("A:A")) + 3 etc. Any help/advice/suggestions would be much appreciated. -- Cheers Peter Remove the INVALID to reply |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Increment by 18 | Excel Worksheet Functions | |||
Exel increment date problem wrt todays date. | Excel Worksheet Functions | |||
Increment | Excel Worksheet Functions | |||
increment a value by 1 | New Users to Excel | |||
need to increment value | Excel Discussion (Misc queries) |