kylefoley76
Well-known Member
- Joined
- Mar 1, 2010
- Messages
- 1,553
I need a macro that will take the cell I'm on plus 78 cells to the right and four rows down, copy and paste the values in them, then replace the cells that have a zero with a blank. The macro below, will go down one cell and over one column and do that.
Also this macro has a bug in the line
cell.value = cell.value
Right now, it's taking everything that's in the first row, copying it, then pasting down 4 rows, so that the next 4 rows all look the same. What I need to do is simply copy and paste the values that are in the next 4 rows, not copy what is in the next row and paste it, so that the next 4 rows are all the same. Thanks
Also this macro has a bug in the line
cell.value = cell.value
Right now, it's taking everything that's in the first row, copying it, then pasting down 4 rows, so that the next 4 rows all look the same. What I need to do is simply copy and paste the values that are in the next 4 rows, not copy what is in the next row and paste it, so that the next 4 rows are all the same. Thanks
Code:
Sub removezeroes()
Dim Cell As Range
Dim RngFrom As Range
Dim RngTo As Range
Set RngFrom = Selection
Set RngTo = Cells(RngFrom.Row + 1, 2).Resize(15, 78)
Cells(RngFrom.Row, 2).Resize(, 78).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