VBA Select Multiple Rows Issue

AllAboutExcel

New Member
Joined
Jun 18, 2018
Messages
2
Hi!

Looking for some assistance with a VBA code. Data will come into the report daily and I want the macro to store the data.

The purpose is that it will select the day previous to yesterday & copy and paste the values. I've got it working - however I've now realised I need to do it for three days previous (to include weekends).

So I want the code to say... 'Find todays date, offset to the row above & select that row plus 2 rows higher.

Here is my current code -


For Each cell In ActiveSheet.Range("A:A")
If cell.Value = [Today()] Then
cell.Offset(-1).EntireRow.Select
End If
Next

Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues



Thanks in advance :)
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Hi & welcome to the board.
If you are trying to change those rows into values try
Code:
Sub chk()
   Dim fnd As Range
   Set fnd = Range("A:A").Find(Date, , , , , , , , False)
   If Not fnd Is Nothing Then
      With fnd.Offset(-3).Resize(3).EntireRow
         .Value = .Value
      End With
   End If
End Sub
 
Upvote 0
Glad to help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,194
Members
452,616
Latest member
intern444

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