Advancing Numbers in Cells by One, Quickly

Nonprof

New Member
Joined
Jul 23, 2017
Messages
8
Hi folks,

I am not sure if I am explaining this right, but here it is...

I have a table, see below. I am tracking the frequencies of specific events by time of day.

Sometimes, I have dozens of datasheets where ALL the times were selected, so I end up manually advancing many of these times or all of them, over and over and over. Quite a drag.

So, I am looking for help with a macro that will automatically advance all frequencies in the table by one, ignoring blank cells.
Being able to advance a 'selection' of times' with the push of a button would be great, too.

Anybody interested and able to help?

[TABLE="width: 209"]
<colgroup><col><col></colgroup><tbody>[TR]
[TD] Occurrence Times[/TD]
[TD]Frequency[/TD]
[/TR]
[TR]
[TD]12:00 AM[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]12:30 AM[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]1:00 AM[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]1:30 AM[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]2:00 AM[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]2:30 AM[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]3:00 AM[/TD]
[TD]2[/TD]
[/TR]
[TR]
[TD]3:30 AM[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]4:00 AM[/TD]
[TD]2[/TD]
[/TR]
[TR]
[TD]4:30 AM[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]5:00 AM[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]5:30 AM[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]6:00 AM[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]6:30 AM[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]7:00 AM[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]7:30 AM[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]8:00 AM[/TD]
[TD]19[/TD]
[/TR]
[TR]
[TD]8:30 AM[/TD]
[TD]26[/TD]
[/TR]
[TR]
[TD]9:00 AM[/TD]
[TD]27[/TD]
[/T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[TR]
[TD]11:00 PM[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]11:30 PM[/TD]
[TD] [/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
For the frequencies and assuming that they are all constants and not formulas try...

Code:
Sub AddOne()
    Dim rngTmp As Range, rngTrg As Range
    Application.ScreenUpdating = False
    
    Set rngTmp = Range("Z1")
    Set rngTrg = Range("B2:B" & Range("A" & Rows.Count).End(xlUp).Row).SpecialCells(2, 1)

    rngTmp.Value = 1
    rngTmp.Copy
    rngTrg.PasteSpecial , xlPasteSpecialOperationAdd
    rngTmp.ClearContents
    
    Application.ScreenUpdating = True
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,981
Messages
6,175,768
Members
452,668
Latest member
mrider123

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