Error Checking in Excel
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 2 of 2

Thread: Macro for Replace with user input

  1. #1
    New Member
    Join Date
    Feb 2002
    Location
    Aberdeen, Scotland, UK
    Posts
    35
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    I have the following macro that goes to the bottom of a range of data, copies the last line of formula's, pastes them into the line below. (this then updates charts using dynamic ranges)

    The macro also finds all references to "feb" and replaces with "mar" to update the formulas to read the next months data.

    However, I want the Macro to use the value in a certain cell (the last populated cell in column A) as the "find" variable, and then ask the user for the "replace" value.

    Anyone know how to do this?

    Macro as is:

    Range("a1").Select
    Selection.End(xlDown).Select
    Range(Selection, Selection.End(xlToRight)).Select
    Selection.Copy
    Range("a1").Select
    Selection.End(xlDown).Offset(1, 0).Select
    Selection.PasteSpecial Paste:=xlAll, Operation:=xlNone, SkipBlanks:=False _
    , Transpose:=False
    Application.CutCopyMode = False
    Selection.replace What:="feb", Replacement:="mar", LookAt:=xlPart, _
    SearchOrder:=xlByRows, MatchCase:=False

  2. #2
    MrExcel MVP
    Join Date
    Feb 2002
    Location
    Bogota, Colombia
    Posts
    11,959
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Use

    What:=Range("A65536").End(xlUp)
    Regards,

    Juan Pablo González
    http://www.juanpg.com

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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