Need help with Macro

Beekman

Board Regular
Joined
Nov 7, 2008
Messages
64
Have no idea about macros, tried a recording but made a mess.

Any help would be greayly appreciated

I have Col B with numbers and Col C with times (in a 24 hr format)

Need to copy Copy Col b4 to last cell and Col C c4 to last cell, copy and paste to Col L4 and M4.

Then order sort Col L4 to last cell and Col M4 to last cell by col M4(times) in ascending order

Then need to border all cells in Col M4 where time is after 19:15 to last cell.

Then copy and paste bordered cells in Col M to another sheet(named intake) to Col A5.

Hope above makes sense

Thanks, Ben
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Have managed to record macro and got it to work except how do I enter code for finding cells 19:15 and later to last cell?

when i recorded macro i just clicked on cell and dragged down to last cell, but this will not find first cell at 19:15 when cell info order changes, and may not be at same cell.

Ben
 
Upvote 0
Code:
Sub Macro1()

    Dim Lastrow As Long
    
    Application.ScreenUpdating = False
    
    ' Last used row in column M
    Lastrow = Range("M" & Rows.Count).End(xlUp).Row
    
    ' Autofilter in column M of time values greater than or equal to 19:15
    Range("M3:M" & Lastrow).AutoFilter Field:=1, Criteria1:=">=19:15"
    
    ' Select visible filtered cells in columns L and M
    Range("L4:M" & Lastrow).SpecialCells(xlCellTypeVisible).Select
    
    ' Turn off Autofilter
    ActiveSheet.AutoFilterMode = False
    
    Application.ScreenUpdating = True
    
End Sub
 
Upvote 0
Thanks AlphaFrog , copy and pasted your macro info into mine and it works fine

When I look back at the sheet the cells after 19:50 has wriggley lines around them and I have to manually press the 'ESC' button on my key board to remove them. It's as if the copy function was't completed.

Is the a line I can add in the macro to do this?

Thanks again, Ben
 
Upvote 0
Put this after you copy and paste to get rid of the "wriggley lines".

Code:
Application.CutCopyMode = True
 
Upvote 0

Forum statistics

Threads
1,224,606
Messages
6,179,865
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