Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default select one range and then go to next


Hi all,

This is my first post. I am new to excel macros. Please help me.

I need to copy from range(H2:M2) in sheet1 and paste it into range(A2)
in sheet2, then go to range(H5:M5), copy that and paste in range(A3)
and so on..

How do i increment the range in a For loop?

Thank you,

ET.


--
excel_lent
------------------------------------------------------------------------
excel_lent's Profile: http://www.excelforum.com/member.php...o&userid=31738
View this thread: http://www.excelforum.com/showthread...hreadid=514524

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default select one range and then go to next

Sub abc()
Dim j as Long, i as Long
j = 2
for i = 2 to 100 step 3
cells(i,"H").Resize(1,6).copy _
worksheets("Sheet2").Cells(j,1)
j = j + 1
Next
end sub

--
Regards,
Tom Ogilvy


"excel_lent" wrote
in message ...

Hi all,

This is my first post. I am new to excel macros. Please help me.

I need to copy from range(H2:M2) in sheet1 and paste it into range(A2)
in sheet2, then go to range(H5:M5), copy that and paste in range(A3)
and so on..

How do i increment the range in a For loop?

Thank you,

ET.


--
excel_lent
------------------------------------------------------------------------
excel_lent's Profile:

http://www.excelforum.com/member.php...o&userid=31738
View this thread: http://www.excelforum.com/showthread...hreadid=514524



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default select one range and then go to next

Hi,

One way:

Sub CopyHM()

Dim ws1 As Worksheet
Dim ws2 As Worksheet
Dim iLastrow As Long, r As Long

Set ws1 = Worksheets("Sheet1")
Set ws2 = Worksheets("Sheet2")
Set orng = ws2.Range("a2")

ws1.Select
With ws1
iLastrow = .Cells(Rows.count, "H").End(xlUp).Row '<=== last row in column H
For r = 2 To iLastrow Step 3 '<=== increment loop by 3 until iLastrow reached
..Cells(r, "H").Resize(1, 6).Copy orng '<=== Resize selects colums H to M (6
columns)
Set orng = orng.Offset(1, 0) '<=== set range to next row in Sheet2
Next r
End With
End Sub


HTH

"excel_lent" wrote:


Hi all,

This is my first post. I am new to excel macros. Please help me.

I need to copy from range(H2:M2) in sheet1 and paste it into range(A2)
in sheet2, then go to range(H5:M5), copy that and paste in range(A3)
and so on..

How do i increment the range in a For loop?

Thank you,

ET.


--
excel_lent
------------------------------------------------------------------------
excel_lent's Profile: http://www.excelforum.com/member.php...o&userid=31738
View this thread: http://www.excelforum.com/showthread...hreadid=514524


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 698
Default select one range and then go to next

Hi ET,

Try this. Copy and right click the sheet 1 tab and click on View Code.
Paste the code in the sheet module, (the white space). Alt+Tab back to the
worksheet and from the Forms tool bar produce a button and assign the macro
to it.

Change For i = 1 To 4 to the number of times you want to loop.

Sub CopyIt()
Dim i As Integer
Range("H2").Select
For i = 1 To 4
ActiveCell.Resize(1, 6).Copy _
Sheets("Sheet2").Range("A100").End(xlUp).Offset(1, 0)
ActiveCell.Offset(4, 0).Select
Next
End Sub

HTH
Regards,
Howard

"excel_lent" wrote
in message ...

Hi all,

This is my first post. I am new to excel macros. Please help me.

I need to copy from range(H2:M2) in sheet1 and paste it into range(A2)
in sheet2, then go to range(H5:M5), copy that and paste in range(A3)
and so on..

How do i increment the range in a For loop?

Thank you,

ET.


--
excel_lent
------------------------------------------------------------------------
excel_lent's Profile:
http://www.excelforum.com/member.php...o&userid=31738
View this thread: http://www.excelforum.com/showthread...hreadid=514524



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
How can change range to select active rows instead of :=Range("S10 ldiaz Excel Discussion (Misc queries) 7 August 29th 08 03:52 PM
When entering data into a range of cells, select the entire range. Q Excel Discussion (Misc queries) 0 September 26th 07 04:36 AM
select range and put range address in variable [email protected] Excel Programming 2 January 25th 06 01:28 AM
Compare a selected Range with a Named range and select cells that do not exist PCLIVE Excel Programming 1 October 18th 05 07:09 PM
Select Sheet then Select Range Gee[_2_] Excel Programming 3 May 27th 04 10:10 PM


All times are GMT +1. The time now is 06:14 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"