VBA to Paste Copied Values to a Separate Row

Darkcloud617

New Member
Joined
Sep 7, 2017
Messages
38
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
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
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
 
Upvote 0

Forum statistics

Threads
1,224,830
Messages
6,181,228
Members
453,025
Latest member
Hannah_Pham93

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top