Trouble using "Do Until"

olafsinsight

New Member
Joined
Jan 27, 2014
Messages
5
This is the goal: I need to get a huge column of numbers into a format to print for a binder. I have a macro that does it one row at a time, but there are 50,000 numbers in the column. I haven't gotten any loop macros to do anything for me yet. I also haven't been able to find an example of a loop that actually does something other than count, but I would love to see one.

This is how I am trying to do it:

Code:
Sub Complete ()
Do Until Cells("K1:K11").Value = " "
Range("K1:K10").Copy
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=True
    Range("K1:K10").Delete Shift:=xlUp
    ActiveCell.Offset(1, 0).Select
            Loop
End Sub

I'm sure it's just a format issue, but it's making me feel pretty silly.
 

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
I can't see how your code does anything useful. What is it supposed to do?
 
Upvote 0
This code mimics what you are doing but changes it a bit.
Code:
Sub Complete2()
Dim i As Integer
Dim j As Integer
Dim lastRow As Integer
Dim rangex As Integer
Dim remand As Integer


lastRow = ActiveSheet.Cells(1, 11).Offset(ActiveSheet.Rows.Count - 1, 0).End(xlUp).Row
rangex = Round(lastRow / 10, 0)
remand = lastRow Mod 10
For i = 1 To rangex
   j = j + 1
   Range("K1:K10").Copy
   Range("L" & j).Select
   Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=True
   Range("K1:K10").Delete Shift:=xlUp
Next i
Range("K1:K" & remand).Copy
Range("L" & (j + 1)).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=True
Range("K1:K" & remand).Delete Shift:=xlUp
End Sub
 
Upvote 0
I can't see how your code does anything useful. What is it supposed to do?

It takes the top ten numbers from column K and pastes them onto the active cell sideways, then selects the cell below that active cell. If I can get it to repeat itself, I could let it format one huge column into a printable book.
 
Upvote 0
I exaggerated the amount of numbers in that column, there are only 43,092. I'm not sure if that makes a difference. I just want my code to rerun until K is blank. Here is the original macro:

Code:
Sub RowRun_1()
    Range("K1:K10").Copy
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=True
    Range("K1:K10").Delete Shift:=xlUp
    ActiveCell.Offset(1, 0).Select
End Sub
 
Upvote 0
If olaf's code otherwise works for you, change the word Integer to Long.
 
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,772
Members
452,353
Latest member
strainu

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