Change macro to start pasting data at row 4

stepone

New Member
Joined
Apr 15, 2013
Messages
2
I have pieced together a macro from reading posts here. Everything works but I would just like it to start pasting the data at row 4 instead of row 2. Any ideas? Thanks.

Code:
Sub GetMyData()
Dim myDir As String, fn As String, sn As String, sn2 As String, n As Long, NR As Long

'***** Change Folder Path *****
'myDir = "C:\TestData"  'for testing
myDir = "C:\Users\stepone\Desktop\DATA FOR EXCEL"

'***** Change Sheetname(s) *****
sn = "Summary Data"


fn = Dir(myDir & "\*.xls")
Do While fn <> ""
  If fn <> ThisWorkbook.Name Then
    With ThisWorkbook.Worksheets(1)
      NR = .Cells(Rows.Count, 1).End(xlUp).Row + 1
      
     
      With .Range("A" & NR)
        .Formula = "='" & myDir & "\[" & fn & "]" & sn & "'!B1"
        .Value = .Value
      End With
      With .Range("B" & NR)
        .Formula = "='" & myDir & "\[" & fn & "]" & sn & "'!B3"
        .Value = .Value
      End With
      With .Range("C" & NR)
        .Formula = "='" & myDir & "\[" & fn & "]" & sn & "'!B4"
        .Value = .Value
      End With
      With .Range("D" & NR)
        .Formula = "='" & myDir & "\[" & fn & "]" & sn & "'!B6"
        .Value = .Value
      End With
      With .Range("E" & NR)
        .Formula = "='" & myDir & "\[" & fn & "]" & sn & "'!B8"
        .Value = .Value
      End With
      With .Range("F" & NR)
        .Formula = "='" & myDir & "\[" & fn & "]" & sn & "'!B19"
        .Value = .Value
      End With
      With .Range("G" & NR)
        .Formula = "='" & myDir & "\[" & fn & "]" & sn & "'!B20"
        .Value = .Value
      End With
      With .Range("H" & NR)
        .Formula = "='" & myDir & "\[" & fn & "]" & sn & "'!B21"
        .Value = .Value
      End With
      With .Range("I" & NR)
        .Formula = "='" & myDir & "\[" & fn & "]" & sn & "'!B23"
        .Value = .Value
      End With
      With .Range("J" & NR)
        .Formula = "='" & myDir & "\[" & fn & "]" & sn & "'!B24"
        .Value = .Value
      End With
      With .Range("K" & NR)
        .Formula = "='" & myDir & "\[" & fn & "]" & sn & "'!B25"
        .Value = .Value
      End With
      With .Range("L" & NR)
        .Formula = "='" & myDir & "\[" & fn & "]" & sn & "'!B26"
        .Value = .Value
      End With
      With .Range("M" & NR)
        .Formula = "='" & myDir & "\[" & fn & "]" & sn & "'!B28"
        .Value = .Value
      End With
      With .Range("N" & NR)
        .Formula = "='" & myDir & "\[" & fn & "]" & sn & "'!B29"
        .Value = .Value
      End With
      With .Range("O" & NR)
        .Formula = "='" & myDir & "\[" & fn & "]" & sn & "'!B31"
        .Value = .Value
      End With
      
      
      
      
    End With
  End If
  fn = Dir
Loop
End Sub
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Try

Code:
NR = WorksheetFunction.Max(4, .Cells(Rows.Count, 1).End(xlUp).Row + 1)
 
Upvote 0

Forum statistics

Threads
1,214,598
Messages
6,120,441
Members
448,966
Latest member
DannyC96

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top