VBA to Paste Copied Values to a Separate Row

Darkcloud617

New Member
Joined
Sep 7, 2017
Messages
26
Hello,

Thank you in advance for any help you may provide. I have cobbled together a VBA code that seems to be working, I just cant get it to paste the copied data correctly.

VBA uses a search box for a user to enter data, it searches Column M for a match and if found it copies a range of cells from another part of the sheet (that all works correctly)... then it SHOULD paste the copied data in the row it found starting at column A. It needs to paste the copied data to the row from the match. There are a total of 9 cells it should paste (again, starting at column A).

I have been tinkering so much with this thing and I am at a loss. Even going back to the basics didnt work. Any help is greatly appreciated.


Code:
Sub exception()
    Dim FindString As String
    Dim Rng As Range
    FindString = InputBox("Enter a Date")
    If Trim(FindString) <> "" Then
        With Sheets("Sheet1").Range("M:M")
            Set Rng = .Find(What:=FindString, _
                            After:=.Cells(.Cells.Count), _
                            LookIn:=xlValues, _
                            LookAt:=xlWhole, _
                            SearchOrder:=xlByRows, _
                            SearchDirection:=xlNext, _
                            MatchCase:=False)
            If Not Rng Is Nothing Then
                    Range("AO18:AW18").Select
                    Application.CutCopyMode = False
                    Selection.Copy
                    ActiveRow.Paste
                    
            Else
                MsgBox "Nothing found"
            End If
        End With
    End If
End Sub
 

MoshiM

Active Member
Joined
Jan 31, 2018
Messages
292
Hello,

Thank you in advance for any help you may provide. I have cobbled together a VBA code that seems to be working, I just cant get it to paste the copied data correctly.

VBA uses a search box for a user to enter data, it searches Column M for a match and if found it copies a range of cells from another part of the sheet (that all works correctly)... then it SHOULD paste the copied data in the row it found starting at column A. It needs to paste the copied data to the row from the match. There are a total of 9 cells it should paste (again, starting at column A).

I have been tinkering so much with this thing and I am at a loss. Even going back to the basics didnt work. Any help is greatly appreciated.
Code:
Sub exception()
    Dim FindString As String
    Dim Rng As Range
    FindString = InputBox("Enter a Date")
    If Trim(FindString) <> "" Then
        With Sheets("Sheet1").Range("M:M")
            Set Rng = .Find(What:=FindString, _
                            After:=.Cells(.Cells.Count), _
                            LookIn:=xlValues, _
                            LookAt:=xlWhole, _
                            SearchOrder:=xlByRows, _
                            SearchDirection:=xlNext, _
                            MatchCase:=False)
            If Not Rng Is Nothing Then
                Range("AO18:AW18").Copy Cells(Rng.Row, 1)
            Else
                MsgBox "Nothing found"
            End If
        End With
    End If
End Sub
 

Darkcloud617

New Member
Joined
Sep 7, 2017
Messages
26
This exactly what I was needing. I cant believe it was such a simple thing. Thank you so much.
 

Forum statistics

Threads
1,086,259
Messages
5,388,728
Members
402,137
Latest member
pkulkarni

Some videos you may like

This Week's Hot Topics

Top