Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 60
Default Help with increment problem please

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Help with increment problem please

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Increment by 18 John Excel Worksheet Functions 1 October 8th 09 02:55 AM
Exel increment date problem wrt todays date. [email protected] Excel Worksheet Functions 1 November 11th 07 06:58 PM
Increment Maria Excel Worksheet Functions 4 November 9th 07 12:10 AM
increment a value by 1 Workshops New Users to Excel 3 March 4th 06 11:06 PM
need to increment value Tom Excel Discussion (Misc queries) 5 June 24th 05 12:54 PM


All times are GMT +1. The time now is 12:17 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"