Copy row to next open row, then paste-value source

KW1M

New Member
Joined
Jul 21, 2020
Messages
13
Office Version
  1. 365
Platform
  1. Windows
Been all through the search and not finding what I need -- I'ma VBA virgin... Think the problem is so simple, I can't find an example to build from!

I have a simple tab/report (blank columns in A, headers, ... just showing data in a sample B2:I3 in this case.
7/16812300.15156158240001800
7/2369150020022026002002000

This tab has values from previous week's reports.

What I want to do is copy (or fill down) the last row with data to the row underneath it. The references are set up to correctly duplicate so my other tabs will report cleanly.
Then the row I just copied (Row 3 in the above example) I would like to copy and paste-value to preserve the data. I've got the rest of the simple macro to clear contents on the other tabs and save the file under a new name -- but this is driving me crazy.

Any suggestions?

Thanks, Martin in NH
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Maybe something like the code below?
VBA Code:
Sub fllDwn()
    With Intersect(Rows(Columns("B:I").Find("*", , xlValues, xlPart, xlByRows, xlPrevious, False).Row), Columns("B:I"))
        .Resize(2).FillDown
        .Offset(1).Value = .Offset(1).Value
    End With
End Sub
 
Last edited:
Upvote 0
Really close - thanks... I see it filling down (good). But I would like to keep the top row as the preserved (paste-value row) and the bottom row is always the one with formulas.

Ran it twice to simulate week 3 and it dupped the bottom.
fill.jpg


It should have looked like
7/16 (now just pasted values)
7/23 (pasted values)
7/30 (live links)

Then I need to figure out how to preserve formatting -- the cells are formatted for accounting (1st 2 with decimals, remaining 4 w/o decimal). Odd that it's not respecting the format on the sheet...

Thanks - I have to read up on what your code is doing.
 
Upvote 0
VBA Code:
Sub fllDwn()
    With Intersect(Rows(Columns("B:I").Find("*", , xlValues, xlPart, xlByRows, xlPrevious, False).Row), Columns("B:I"))
        .Resize(2).FillDown
        .Value = .Value
    End With
End Sub
7/16 if it is a real date formatted and the only cell in the selection to filldown will give 7/17 not 7/23. To get 7/23 in a filldown it would have to be 2 cells 7/09 & 7/16 selected and filled down.
 
Last edited:
Upvote 0
Thanks Mark -- perfect solution!

I had to change formatting to currency and that seems to work. Accounting gave me fits.

Appreciate the help! Martin
 
Upvote 0
You might want to try...
VBA Code:
Sub fllDwn()
    With Intersect(Rows(Columns("B:I").Find("*", , xlValues, xlPart, xlByRows, xlPrevious, False).Row), Columns("B:I"))
       .AutoFill .Resize(2), xlFillDefault
        .Value = .Value
    End With
End Sub
 
Upvote 0
Thanks Mark -- works like a charm...

If I may ask... wouldn't this code below set the numeric value of a cell to "1"?
VBA Code:
    Range("E8:E13").Select
    ActiveCell.FormulaR1C1 = "1"

I'm resetting one of my tables where values may be 2, 3, 1... and want to start fresh with 1.
 
Upvote 0
Figured it out... need to set value - this worked:

VBA Code:
    Dim cellRange As Range
    Set cellRange = Range("E4:E6")
    cellRange.Value = "1"

Repeated as necessary as my ranges down column E are not contiguous.

Whew -- I'm in business. Thanks Mark for all the help!
 
Upvote 0
Sets it as a text of 1, lose the brackets if you want it as a numeric value...
VBA Code:
cellRange.Value = 1
 
Upvote 0

Forum statistics

Threads
1,215,548
Messages
6,125,468
Members
449,230
Latest member
ASBeard

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