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?

Occurrence TimesFrequency
12:00 AM1
12:30 AM
1:00 AM
1:30 AM
2:00 AM
2:30 AM
3:00 AM2
3:30 AM
4:00 AM2
4:30 AM
5:00 AM
5:30 AM
6:00 AM
6:30 AM
7:00 AM
7:30 AM1
8:00 AM19
8:30 AM26
9:00 AM27
9:30 AM37
10:00 AM42
10:30 AM64
11:00 AM46
11:30 AM44
12:00 PM46
12:30 PM44
1:00 PM50
1:30 PM44
2:00 PM44
2:30 PM36
3:00 PM14
3:30 PM10
4:00 PM18
4:30 PM23
5:00 PM17
5:30 PM26
6:00 PM25
6:30 PM27
7:00 PM16
7:30 PM7
8:00 PM1
8:30 PM
9:00 PM
9:30 PM
10:00 PM
10:30 PM
11:00 PM
11:30 PM

<colgroup><col><col></colgroup><tbody>
</tbody>
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
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,214,983
Messages
6,122,592
Members
449,089
Latest member
Motoracer88

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