PC Review


Reply
Thread Tools Rate Thread

autofill variable lenght column w/ sequential numbers using VBA

 
 
Billyruben
Guest
Posts: n/a
 
      25th Nov 2008
Problem: Sort data contained in an area defined by X number of columns and Y
number of rows, then sort the data back to its orginal row order.

Normally: Before the initial sort, add an extra column and assign a unique
number to each row. Sort using this extra column will restore the original
row order.

I can record a macro and display the VBA code without a problem.

Question: Write the code identifying the last sort row when # of rows not
constant. eg: Selection.AutoFill Destination:=Range("F5:F??"),
Type:=xlFillDefault. I can count the # of rows, but how do I store that
number, then pass it to the Range requirements?
 
Reply With Quote
 
 
 
 
Shane Devenshire
Guest
Posts: n/a
 
      25th Nov 2008
Hi

Dim Bottom as Long
Bottom = Range("A65536").End(XLUp).Row
Selection.AutoFill Destination:=Range("F5:F" & Bottom)

I picked colum A to find the bottom of the data, but you can pick any column
where the data extends down as far as you want the fill.

If this helps, please click the Yes button

Cheers,
Shane Devenshire

"Billyruben" wrote:

> Problem: Sort data contained in an area defined by X number of columns and Y
> number of rows, then sort the data back to its orginal row order.
>
> Normally: Before the initial sort, add an extra column and assign a unique
> number to each row. Sort using this extra column will restore the original
> row order.
>
> I can record a macro and display the VBA code without a problem.
>
> Question: Write the code identifying the last sort row when # of rows not
> constant. eg: Selection.AutoFill Destination:=Range("F5:F??"),
> Type:=xlFillDefault. I can count the # of rows, but how do I store that
> number, then pass it to the Range requirements?

 
Reply With Quote
 
Billyruben
Guest
Posts: n/a
 
      28th Nov 2008
Excellent! Thanks, I've used the value stored in Bottom for accomplishing
other things. (e.g. discovered that Range("A" & Bottom + n).Select, selects
the cell located n number of rows below the value of Bottom)

Please allow me to impose on you once more:

(I know zilch about VBA syntax.)

What is the VBA equivelant of CtrlShiftSpacebar - e.g. select an area of
contiguous cells, each containing data. Start by selecting the topmost cell
containing data at the leftmost column.

What is a good source for the code equivalents for keyboard shortcuts?
(Other than you, of course)

Thanks for being out there.
Ruben

"Shane Devenshire" wrote:

> Hi
>
> Dim Bottom as Long
> Bottom = Range("A65536").End(XLUp).Row
> Selection.AutoFill Destination:=Range("F5:F" & Bottom)
>
> I picked colum A to find the bottom of the data, but you can pick any column
> where the data extends down as far as you want the fill.
>
> If this helps, please click the Yes button
>
> Cheers,
> Shane Devenshire
>
> "Billyruben" wrote:
>
> > Problem: Sort data contained in an area defined by X number of columns and Y
> > number of rows, then sort the data back to its orginal row order.
> >
> > Normally: Before the initial sort, add an extra column and assign a unique
> > number to each row. Sort using this extra column will restore the original
> > row order.
> >
> > I can record a macro and display the VBA code without a problem.
> >
> > Question: Write the code identifying the last sort row when # of rows not
> > constant. eg: Selection.AutoFill Destination:=Range("F5:F??"),
> > Type:=xlFillDefault. I can count the # of rows, but how do I store that
> > number, then pass it to the Range requirements?

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Autofill with Column as a variable LuisE Microsoft Excel Programming 5 17th Aug 2008 09:00 AM
Fill a column with sequential numbers GISDude Microsoft Excel Misc 4 1st May 2006 02:41 PM
Fill a column with sequential numbers GISDude Microsoft Excel Misc 3 1st May 2006 02:01 AM
variable column numbers for autofill mattybinv Microsoft Excel Programming 1 8th Dec 2005 01:06 PM
how do I autofil a column with sequential numbers? =?Utf-8?B?WWVzcmVr?= Microsoft Excel Misc 2 20th Nov 2005 03:28 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:14 AM.