vba do until (i think)

irenesboy

Board Regular
Joined
May 28, 2004
Messages
90
Can somebody help me with this macro
I want to run this macro until it reaches a blank cell.
Thank you very much for your help.
irenesboy

Macro1 Macro
' FormatSchedule
'

'
Range("A3").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=R[1]C"
Range("A5").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=R[1]C"
Range("A7").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=R[1]C"
End Sub
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
What does your initial data look like?
What exactly is this macro supposed to do?
 
Upvote 0
Change the NumberFormat line to whatever time format you are using:

Code:
Sub test()
Dim x As Long
For x = 4 To Range("A" & Rows.Count).End(xlUp).Row Step 2
    With Cells(x - 1, 1)
        .Value = Cells(x, 1)
        .NumberFormat = "hh:mm"
    End With
Next
End Sub
 
Upvote 0
When you say run into it reaches a blank, you actually mean that the cell below the one you are entering into is blank, right?
So, does that mean every other row is populated to start (A3 blank, A4 has data, A5 blank, A6 has data, etc)?
 
Upvote 0
If my previous assumption is correct (every other row is blank), here is a method that uses no loops (so is it more efficient):
Code:
Sub MyPopulateRange()

    Dim lastRow As Long
    
'   Find last cell with data in column A
    lastRow = Cells(Rows.Count, "A").End(xlUp).Row
    
'   Select all blank cells in range
    Range("A3:A" & lastRow).SpecialCells(xlCellTypeBlanks).FormulaR1C1 = "=R[1]C"
    Range("A3:A" & lastRow).Value = Range("A3:A" & lastRow).Value
    
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,164
Messages
6,170,444
Members
452,326
Latest member
johnshaji

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