VBA paste range of cells based on cell value in a range

dannyh

Board Regular
Joined
Oct 15, 2007
Messages
156
Hi

I am trying to copy a range of cells on a sheet which will change every month and paste them to a summary sheet that remains constant, I think I am nearly there but need to add a line of code.


VBA Code:
Dim shtName As String
    shtName = ActiveSheet.Name

Range("I3:O3").Copy
    Worksheets("AR Aging").Activate
    
    Dim FindString As String
    Dim Rng As Range
    FindString = shtName
    If Trim(FindString) <> "" Then
        With Sheets("AR Aging").Range("A:A")
            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
                
                ActiveCell.Offset(0, 1).PasteSpecial
            Else
                MsgBox "Nothing found"
            End If
        End With
    End If

This piece of code works
VBA Code:
ActiveCell.Offset(0, 1).PasteSpecial
except that the ActiveCell is not the cell found within the searched range it is any random cell.

Could someone advise me of the additional code needed to select the found cell first please.

Thanks Dan
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Maybe
VBA Code:
Rng.Offset(0, 1).PasteSpecial
 
Upvote 0

Forum statistics

Threads
1,213,511
Messages
6,114,054
Members
448,543
Latest member
MartinLarkin

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