Thanks Thanks:  0
Likes Likes:  0
Results 1 to 2 of 2

Thread: Macro question

  1. #1
    New Member
    Join Date
    Mar 2002
    Posts
    2
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    I am trying to record a macro that copies from one sheet and pastes info to another sheet based on a find. When i look at the vbe it shows:

    Cells.Find(What:="100* Total", After:=ActiveCell, LookIn:=xlFormulas, _
    LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
    MatchCase:=False, SearchFormat:=False).Activate
    Range("A27:M27").Select
    Range("M27").Activate

    As you can see the problem is that it always copies a "hard" range as opposed to the next appropriate range. Can anyone tell me how to fix this? Thanks

  2. #2
    MrExcel MVP Ivan F Moala's Avatar
    Join Date
    Feb 2002
    Location
    Auckland, New Zealand
    Posts
    4,209
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Something along these lines may help;

    Sub FindCopy()
    Dim Found As Range

    Set Found = Cells.Find(What:="100 TOTAL", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
    :=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
    False)
    If Found Is Nothing Then MsgBox "Not found!": Exit Sub
    Found.Copy Sheets("Sheet2").Range("A1")

    End Sub

    'Notes copies the cell to Sheet2 A1
    'change as required

    Ivan

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
  •