Results 1 to 3 of 3

Error with an Array in a macro

Threaded View

  1. #1
    Registered User
    Join Date
    07-14-2008
    Location
    INDIA
    Posts
    78

    Error with an Array in a macro

    Hi,

    I am a starter in VBA. Below is apart of code in which I am getting run time error 13 at the bolded and the under lined line. Can I have some suggestions how to rectify this.
    Option Base 1
    Sub sheetName()
     
    Dim ws As Worksheet
    Dim myArray As Variant
     
    Set ws = Worksheets.Add
    ws.Name = "List"
    ws.Move After:=Sheets(Sheets.Count)
    With ws
        For i = 1 To Sheets.Count - 1
            .Cells(i, 1).Value = Sheets(i).Name
        Next i
    End With
    lr = ws.Range("A" & Rows.Count).End(xlUp).Row
    For j = 1 To lr
        myArray(j) = ws.Cells(j, 1).Value
    Next j
    For n = 1 To lr
        myArray(n).Range("A1:D4").Interior.ColorIndex = 6
     
    Next n
    End Sub
    Any Help on where I am going wrong.

    Posted here also but invain:http://www.mrexcel.com/forum/showthread.php?t=388162
    Last edited by TRJJK73; 05-05-2009 at 05:41 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1