Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Increasing Row Value

Hi there,
Just wondering if anyone could help me with the following problem:

Range("A240:G240").Select
Selection.Copy
Range("A241").Select
ActiveSheet.Paste
Range("A240:G240").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("A242").Select

Each time I run the macro, I want the row value to be increasing (i.e.
A240:G240 to A241 to:G240). Range A240-G240 refers to the value from
another sheet which has to be copied to the following row and then
paste the value to A240-G240 (no formulas).

If anyone could help, that would be really appreciated.
Thanks
AN
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Increasing Row Value

I don't follow exactly what you want to do, eg

(i.e. A240:G240 to A241 to:G240) ?


but in essence you want to increment a counter, here are two different
approaches. Use the name method if you want the row to increment down
between sessions

Sub test1()
Dim rng As Range
Static nRow As Long

If nRow = 0 Then
nRow = 240
Else
nRow = 240 + 1
End If

With ActiveSheet
Set rng = .Range(.Cells(nRow, 1), .Cells(nRow, 6))
End With

MsgBox rng.Address

End Sub

Sub test2()
Dim rng As Range

On Error Resume Next
Set rng = Range("aName")
On Error GoTo 0
If rng Is Nothing Then
Set rng = ActiveSheet.Range("A240:G240")
ActiveWorkbook.Names.Add "aName", rng
' optional
' ActiveWorkbook.Names("aName").Visible = False
End If
MsgBox rng.Address
ActiveWorkbook.Names.Add "aName", rng.Offset(1)

End Sub

BTW, no need to select anything in your code

Regards,
Peter T






wrote in message
...
Hi there,
Just wondering if anyone could help me with the following problem:

Range("A240:G240").Select
Selection.Copy
Range("A241").Select
ActiveSheet.Paste
Range("A240:G240").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("A242").Select

Each time I run the macro, I want the row value to be increasing (i.e.
A240:G240 to A241 to:G240). Range A240-G240 refers to the value from
another sheet which has to be copied to the following row and then
paste the value to A240-G240 (no formulas).

If anyone could help, that would be really appreciated.
Thanks
AN



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
increasing a cell value on each use dave Excel Worksheet Functions 3 July 27th 07 11:06 PM
Increasing by a percent Nicole Excel Discussion (Misc queries) 1 October 10th 06 08:50 PM
increasing a cell by 1 Debra Excel Worksheet Functions 3 October 6th 06 04:41 PM
increasing percentage S S Excel Worksheet Functions 3 May 6th 06 05:57 PM
Increasing M in M/D/Y Bill45 Excel Discussion (Misc queries) 2 May 19th 05 06:32 PM


All times are GMT +1. The time now is 03:49 PM.

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"