Results 1 to 3 of 3

Using a variable to define a range in VBA

Threaded View

  1. #1
    Registered User
    Join Date
    04-18-2011
    Location
    Melbourne
    MS-Off Ver
    Excel 2003
    Posts
    70

    Using a variable to define a range in VBA

    Hi,

    I have 2 questions:

    Question 1

    I have a sheet with cols A:K, row 1 is the headings. Cell N1 is a calculation to return how many rows there are is a different part of the work book.

    for this assume that N1=100

    In A2:K2 I have formulea that need copied down 100 rows (given that N1=100)

    I have tried the following code:

    Sub CD6007()
    '
    ' CD6007 Macro
    '
    '
        Dim rows As Integer
        Set rows = Cells(1, 13).Value
        Range("A2:K2").Select
        Selection.AutoFill Destination:=Range("B2:K" & rows), Type:=xlFillDefault
        
    End Sub
    But this is not working.

    Please can someone help me, i cannot work out what is wrong with it!

    Question 2

    I have a column that is populated with different text values and some blanks, what VBA would i use to search this column and replace all blank cells with the word "BLANK"

    I have tried

    Sub BLANK()
    
            Dim rows As Integer
            Set rows = Cells(1, 13).Value
    	Range("D1:D" & rows).SpecialCells(xlCellTypeBlanks) = "Blank"
    
    End Sub
    Thanks very much in advance

    P.S. I only started looking at VBA recently so i apologize if these are simple/stupid questions..
    Last edited by MysticGenius; 11-01-2011 at 01:40 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