very simple macro needed

kylefoley76

Well-known Member
Joined
Mar 1, 2010
Messages
1,553
i need a macro where it selects cells b to br, copies them, then goes down a row and pastes 4 rows. for example, if the selection was on b56, it would select b56:br56, then copy, then paste b57:br61. but i need the macro to be set up where it copies and pastes according to that one function, i forget its name, it's something where you specify the cells according to the cell you're on, like if you're at a1, then b2 would be [-1,-1]. thanks in advance.
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
I just though of something else I need for this macro. After I copy and paste, let's say b56:br61. I then need to select b52:br56, copy them, paste values, then find zeroes and replace them with a blank. Thanks in advance.
 
Upvote 0
Try:
Code:
 Sub CopyRow4x()
   'You only need to be on the row when macro starts.
   Dim Rng As Range
   Set Rng = Selection
 
   Cells(Rng.Row, 2).Resize(, 69).Copy Destination:=Cells(Rng.Row + 1, 2).Resize(4)
 
   Set Rng = Nothing
 
End Sub
 
Upvote 0
Try:

Code:
Sub CopyRow4x()
   'You only need to be on the row when macro starts.
   Dim RngFrom As Range
   Dim RngTo As Range
 
   Set RngFrom = Selection
   Set RngTo = Cells(RngFrom.Row + 1, 2).Resize(4, 69)
 
   Cells(RngFrom.Row, 2).Resize(, 69).Copy Destination:=RngTo
 
   With RngTo
      .Value = .Value
      .Activate
   End With
 
   Set RngFrom = Nothing
   Set RngTo = Nothing
End Sub
 
Upvote 0
Try
Code:
Sub CopyRow4x()
   'You only need to be on the row when macro starts.
   Dim Cell As Range
   Dim RngFrom As Range
   Dim RngTo As Range
 
   Set RngFrom = Selection
   Set RngTo = Cells(RngFrom.Row + 1, 2).Resize(4, 69)
 
   Cells(RngFrom.Row, 2).Resize(, 69).Copy Destination:=RngTo
 
   For Each Cell In RngTo
      If Cell.Value = 0 Then
         Cell.Value = ""
      Else
         Cell.Value = Cell.Value
      End If
   Next Cell
 
   RngTo.Activate
 
   Set Cell = Nothing
   Set RngFrom = Nothing
   Set RngTo = Nothing
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,602
Messages
6,179,839
Members
452,948
Latest member
UsmanAli786

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