Results 1 to 1 of 1
  1. #1
    Join Date
    Dec 2012
    Posts
    28

    Exclamation Unanswered: Repeat Excel Macro

    Hi. I'm using excel 2010 and I have a macro that works great. However, I want it to repeat. I'm trying to repeat it from Sheet1 Row A2 instead of A1 by using the following code:
    The way I current have it, it works great for whatever is in A1 but then it stops. Doesn't keep going for A2.

    Code:
    Sub test()
      
        Sheets("Sheet1").Select
        Range("A1").Select
        Selection.Copy
        Sheets("OSDS").Select
        Range("B2").Select
        ActiveSheet.Paste
        Application.CutCopyMode = False
        Application****n "CustomerData.xlsm!RefreshQuery"
        Range("Table_Query_from_CustData[[#Headers],[FileName]]").Select
        Range(Selection, Selection.End(xlToRight)).Select
        Range(Selection, Selection.End(xlDown)).Select
        Selection.Copy
        Sheets.Add After:=Sheets(Sheets.Count)
        ActiveSheet.Paste
        Range("G29").Select
        Sheets("OSDS").Select
        ActiveWindow.ScrollColumn = 25
        ActiveWindow.ScrollColumn = 22
        ActiveWindow.ScrollColumn = 3
        ActiveWindow.ScrollColumn = 1
        
    FinalRow = Cells(Rows.Count, 1).End(xlUp).Row
       For i = 1 To FinalRow
        ThisValue = Cells(i, 1)
        ThisCode = Cells(i, 2)
        Cells(i, ThisValue).Value = ThisCode
    
    Next i
    
    End Sub
    I get a runtime de bug error for the following line:
    Code:
    Cells(i, ThisValue).Value = ThisCode

    Any help is greatly apperciated. Thanks!
    Last edited by AccessN00b; 02-27-13 at 19:26.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •