+ Reply to Thread
Results 1 to 10 of 10

Macro problem for absolute reference

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    04-29-2011
    Location
    South Korea
    MS-Off Ver
    Excel 2019
    Posts
    178

    Re: Macro problem for absolute reference

    Thanks for your reply.

    After i put the following code, it still doesn't work.
    On the sheet "before macro", it still turn to value# (cell A 1to B7)
    By the way, should i change sheets(1) of the macro to sheet(before macro)?

    With Sheets(before macro) 'the number being the sheet you want to run code on
    instead of
    With Sheets(1) 'the number being the sheet you want to run code on


    Sub Absolute()
    Dim cell As Range
     
    With Sheets(1) 'the number being the sheet you want to run code on
     
    For Each cell In Selection
    If cell.HasFormula Then
    cell.Formula = Application.ConvertFormula _
    (cell.Formula, xlA1, xlA1, xlAbsolute)
    End If
    Next
    end with
     
    End Sub

    Moreover, the 2nd macro you write may be incomplete. what is the purpose of macro?

    Sub Absolute()
    Dim cell As Range
     
    'Sheets(1).Select or Sheets(1).Activate The number being the sheet you want to run the code on.
     
    For Each cell In Selection
    If cell.HasFormula Then
    cell.Formula = Application.ConvertFormula _
    (cell.Formula, xlA1, xlA1, xlAbsolute)
    End If
    Next

  2. #2
    Valued Forum Contributor realniceguy5000's Avatar
    Join Date
    03-20-2008
    Location
    Fl
    MS-Off Ver
    Excel 2003 & 2010
    Posts
    951

    Re: Macro problem for absolute reference

    Hi,

    I was only just giving you examples to try not complete scripts you only need to try one of the ways to see if it works. After the Dim statement try one of these methods:

    Sheets(1).Select 
     
    OR 
     
    Sheets("THE NAME OF THE SHEET YOU WANT THE CODE TO RUN ON").Select
     
    Or
     
    Sheets(1).Activate
     
    or
     
    With Sheets("THE NAME OF THE SHEET YOU WANT THE CODE TO RUN ON")
     
    And place End With After the current End With in the script.
    .

    Also
    Sheets(before macro)
    .
    Should be like this:

    Sheets("before macro")
    The number I was talking about is the count of the worksheets you want to run your code on. For example you open a new workbook you have 3 sheet tabs with the names sheet1 ,sheet2 and sheet3 Say you want to run code on sheet2 you could use sheets("sheet2") by the name of the worksheet or sheets(2) by the index number placement of the worksheet.

    You dont really need to activate or select a worksheet to make a script work but it may help you to see what your script is doing when you step through it.

    Hope that helps some.
    Thank You, Mike

    Some Helpful Hints:

    1. New members please read & follow the Forum Rules
    2. Use Code Tags...Place[code]Before the first line and[/code] After the last line.
    3. If you are pleased with a solution mark your post SOLVED.
    4. Thank those who have help you by clicking the scales at the top right of the post.

    Here...

  3. #3
    Forum Contributor
    Join Date
    04-29-2011
    Location
    South Korea
    MS-Off Ver
    Excel 2019
    Posts
    178

    Re: Macro problem for absolute reference

    I tried to use the following macro, its work.
    However, A1 to B7 still return to value# after I use macro (on sheet "before macro")

    I believe I may need to modify the following macro....

    Sub Absolute()
    Dim cell As Range
     
    With Sheets("before macro")
     
    For Each cell In Selection
    If cell.HasFormula Then
    cell.Formula = Application.ConvertFormula _
    (cell.Formula, xlA1, xlA1, xlAbsolute)
    End If
    Next
    End With
     
    End Sub

+ Reply to Thread

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