#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 16
Default Macro problem

I have had someone write me a macro as below. This basically copies the top
10 numbered rows from Sheet 1 and pastes into Sheet 3. However it pastes the
rows starting from Row 1 in Sheet 3 therfore not allowing me to put any
column headings/titles etc. in Sheet 3. I need the info to be pasted from row
8 and below rather than row 1. Any help?

Sub MyMacro()
Dim lngRow As Long, ws As Worksheet, lngNRow As Long
Set ws = Sheets("Sheet3")
For lngRow = 1 To Cells(Rows.Count, "A").End(xlUp).Row
If Range("A" & lngRow) 0 And Range("A" & lngRow) <= 10 Then
lngNRow = lngNRow + 1: Rows(lngRow).Copy ws.Rows(lngNRow)
End If
Next
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default Macro problem

Hi,

Note the very minor change to the last line befor end if

Sub MyMacro()
Dim lngRow As Long, ws As Worksheet, lngNRow As Long
Set ws = Sheets("Sheet3")
For lngRow = 1 To Cells(Rows.Count, "A").End(xlUp).Row
If Range("A" & lngRow) 0 And Range("A" & lngRow) <= 10 Then
lngNRow = lngNRow + 1: Rows(lngRow).Copy ws.Rows(lngNRow + 7)
End If
Next
End Sub

Mike

"The Message" wrote:

I have had someone write me a macro as below. This basically copies the top
10 numbered rows from Sheet 1 and pastes into Sheet 3. However it pastes the
rows starting from Row 1 in Sheet 3 therfore not allowing me to put any
column headings/titles etc. in Sheet 3. I need the info to be pasted from row
8 and below rather than row 1. Any help?

Sub MyMacro()
Dim lngRow As Long, ws As Worksheet, lngNRow As Long
Set ws = Sheets("Sheet3")
For lngRow = 1 To Cells(Rows.Count, "A").End(xlUp).Row
If Range("A" & lngRow) 0 And Range("A" & lngRow) <= 10 Then
lngNRow = lngNRow + 1: Rows(lngRow).Copy ws.Rows(lngNRow)
End If
Next
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 16
Default Macro problem

Thanks Mike, I knew it would be something simple like that but very
inexperienced at Macro's so normally need help. Thanks a lot!

"Mike H" wrote:

Hi,

Note the very minor change to the last line befor end if

Sub MyMacro()
Dim lngRow As Long, ws As Worksheet, lngNRow As Long
Set ws = Sheets("Sheet3")
For lngRow = 1 To Cells(Rows.Count, "A").End(xlUp).Row
If Range("A" & lngRow) 0 And Range("A" & lngRow) <= 10 Then
lngNRow = lngNRow + 1: Rows(lngRow).Copy ws.Rows(lngNRow + 7)
End If
Next
End Sub

Mike

"The Message" wrote:

I have had someone write me a macro as below. This basically copies the top
10 numbered rows from Sheet 1 and pastes into Sheet 3. However it pastes the
rows starting from Row 1 in Sheet 3 therfore not allowing me to put any
column headings/titles etc. in Sheet 3. I need the info to be pasted from row
8 and below rather than row 1. Any help?

Sub MyMacro()
Dim lngRow As Long, ws As Worksheet, lngNRow As Long
Set ws = Sheets("Sheet3")
For lngRow = 1 To Cells(Rows.Count, "A").End(xlUp).Row
If Range("A" & lngRow) 0 And Range("A" & lngRow) <= 10 Then
lngNRow = lngNRow + 1: Rows(lngRow).Copy ws.Rows(lngNRow)
End If
Next
End Sub

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
Problem with macro Dazed and Confused[_2_] New Users to Excel 2 March 7th 09 11:48 PM
Macro Problem albertmb Excel Discussion (Misc queries) 7 September 24th 08 04:46 AM
I tried to get around the problem of the pivot table field settingdefaulting to Count instead of Sum by running a macro of change the settingfrom Count to Sum. However, when I tried to run the Macro, I got error messageof run time error 1004, unable Enda80 Excel Worksheet Functions 1 May 3rd 08 02:35 PM
I tried to get around the problem of the pivot table field settingdefaulting to Count instead of Sum by running a macro of change the settingfrom Count to Sum. However, when I tried to run the Macro, I got error messageof run time error 1004, unable Enda80 Excel Discussion (Misc queries) 1 May 3rd 08 10:52 AM
Macro problem [email protected] Excel Discussion (Misc queries) 6 January 2nd 07 09:22 PM


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