Results 1 to 3 of 3

absolute reference in macro

Threaded View

jw01 absolute reference in macro 12-21-2010, 02:29 AM
JBeaucaire Re: absolute reference in... 12-21-2010, 03:39 AM
NBVC Re: absolute reference in... 12-21-2010, 09:32 AM
  1. #1
    Forum Contributor
    Join Date
    11-26-2010
    Location
    usa
    MS-Off Ver
    Office 365
    Posts
    1,233

    absolute reference in macro

    hello i have the following macro that changes the changes one of the references in the cells...

    Sub CreateFormulas()
    Dim ws As Worksheet
    Dim MainPath As String
    Dim CityBk As String
    Dim Rw As Long
    Application.DisplayAlerts = False
    
    MainPath = "='C:\Documents and Settings\Archieve 2011\"
    
    For Each ws In Worksheets
        If ws.Range("C5") = "Period" Then
            CityBk = "\[" & ws.Name & ".xls]G.S Branch'!"
            For Rw = 7 To 1119 Step 21
                Range("C" & Rw + 1, "M" & Rw + 20).Formula = MainPath & Range("C" & Rw) & CityBk & "C" & Rw - 2
                Range("N" & Rw + 1, "Y" & Rw + 20).Formula = MainPath & Range("C" & Rw) & CityBk & "O" & Rw - 2
            Next Rw
        End If
    Next ws
    
    End Sub
    i have attached a sample workbook, if you notice, each range in columns (E:Y) uses P1W1, P1W2...P12W5 to derive the end result....and at the end the cell reference is an abolute value.

    when i run the above macro, although it does what i want by inserting the correct period/week i.e. P1W1 ..or P2W1 in its corresponding column, it doesnt however keep the i.e. $E$8 or $Y$28 or $H$45 etc absolute, it makes it relative and thus drags the formula down.......so can anyone help pls its been realy hampering the whole file...i have 33 more worksheets to add an this macro does it rvery quick, just changes the references. thx you, happy holidays
    Attached Files Attached Files

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