VBA Copy & Paste Values onto itself based on Criteria

mst3kr

New Member
Joined
Apr 15, 2013
Messages
46
Office Version
  1. 2019
  2. 2010
  3. 2007
Platform
  1. Windows
Hello.

I have a file of roughly 250 lines that I update 3x/day where the primary report page is filled with formulas as the background data will change throughout the day, day to day. There is a Status column that is manually updated each time the report is refreshed and an order shows it is Ready. When the status is Ready, I need a cell range in that row to have its data copied & pasted as a value onto itself. I also need this copy & paste exercise to be duplicated for all rows where the Status is Ready. I have several VBAs currently written in the file but haven't been able to write one that will read all lines each time a script is run...

Below is a sample of what the spreadsheet looks like. Any help would be appreciated!

ABCDEFGHIJKLMNO
POOrderedDueItem #Order QtyUnitsPalletsItemJob #MachReady DateReady TimeStatusCarrierTrailer
14-Jan07-Feb15220.0217-Feb18:00
211-Jan07-Feb210420.0431-Feb12:43Ready1
326-Jan07-Feb315620.0651-Feb18:11Shipped2
426-Jan07-Feb420820.0876-Feb15:30
526-Jan07-Feb5251020.01092-Feb00:48Shipped3
614-Dec08-Feb6301220.012112-Feb13:43Ready4
711-Jan08-Feb7351420.0141326-Jan17:21Ready
826-Jan08-Feb8401620.016152-Feb10:55Ready5
926-Jan08-Feb9451820.018172-Feb02:33Ready6
1026-Jan08-Feb10502020.020191-Feb21:03Ready7
 

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
Give this code a shot. This will paste the entirerow as values. Can you specify what range you want to copy and paste as value?

VBA Code:
Sub mst3kr()
Dim i As Long
Dim lr As Long

lr = Range("A" & Rows.Count).End(xlUp).Row

For i = 2 To lr

    If Range("M" & i).Value = "Ready" Then Range("A" & i).EntireRow.Value = Range("A" & i).EntireRow.Value
Next
End Sub
 
Upvote 0
Another option...
VBA Code:
Sub Convert_Ready()
    With ActiveSheet
        If .AutoFilterMode Then .AutoFilter.ShowAllData
        With .Range("A1").CurrentRegion
            .AutoFilter 13, "Ready"
            If .SpecialCells(xlCellTypeVisible).Address <> .Rows(1).Address Then
                With .Offset(1).SpecialCells(xlCellTypeFormulas)
                    .Value = .Value
                End With
            End If
            .AutoFilter
        End With
    End With
End Sub
 
Upvote 0
I had a look at an event macro for you, so you don't need to run it manually each time, but will check the data to see if the cells have changed and if it equals Ready if will run. It checks column M because thats the one you have in your test data, but if the ranges are different you can update the code to match your data. This needs to be placed in the Sheet, not in the module.
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("M:M")) Is Nothing Then
    If Target.Value = "Ready" Then
        Range("A" & Target.Row & ":L" & Target.Row).Value = Range("A" & Target.Row & ":L" & Target.Row).Value
        Range("N" & Target.Row & ":O" & Target.Row).Value = Range("N" & Target.Row & ":O" & Target.Row).Value
        Else
    End If
End If
End Sub
 
Upvote 0
Solution
Coyote, kevin, dermie... Thank you very much for your help! I was able to test each of your codes and (after making range adjustments) they all work perfectly! I really appreciate your assistance with this! This will make things MUCH easier when dealing with this file everyday...
 
Upvote 1

Forum statistics

Threads
1,224,816
Messages
6,181,143
Members
453,021
Latest member
Justyna P

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