Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 147
Default Fill column question

Hi group,

I have a problem that I have seen similar answers for, but they are not
specific enough to my problem.

I have gotten close by looking at other examples, but I'm not having much
luck modifying the code.

What I would like to do is to create a macro that populates a certain column
(J) from J2 to the last row of data. For example, sometimes the range will be
J2:J200 or J2:J333 - it's never constant.

My macro so far just fills one cell (J2) and selects it so that the corner
handle is visible - the user just has to grab it and drag down the column.

It would be great if this step could be automated.

My macro looks like this:

Sub Bank_InsertWorkTypeID()
ActiveSheet.Range("J2").Value = 00000
End Sub

Thanks,
Christine
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default Fill column question

Sub Auto_Fill()
Dim lRow As Long
With ActiveSheet
lRow = .Range("A" & Rows.Count).End(xlUp).Row
.Range("J2").Value = "'00000"
.Range("J2:J" & lRow).FillDown
End With
End Sub


Gord Dibben MS Excel MVP

On Mon, 15 Mar 2010 14:02:04 -0700, Christine
wrote:

Hi group,

I have a problem that I have seen similar answers for, but they are not
specific enough to my problem.

I have gotten close by looking at other examples, but I'm not having much
luck modifying the code.

What I would like to do is to create a macro that populates a certain column
(J) from J2 to the last row of data. For example, sometimes the range will be
J2:J200 or J2:J333 - it's never constant.

My macro so far just fills one cell (J2) and selects it so that the corner
handle is visible - the user just has to grab it and drag down the column.

It would be great if this step could be automated.

My macro looks like this:

Sub Bank_InsertWorkTypeID()
ActiveSheet.Range("J2").Value = 00000
End Sub

Thanks,
Christine


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 65
Default Fill column question

You could also assign the entire range at once since every cell is
getting the same value. Change A65536 to whatever is your longest
column.

Sub Test()
ActiveSheet.Range("J2","J"&Range("A65536").End(xlu p).row).Value=0
End Sub

Alternately, consider assigning the last row number to a variable to
make your code easier to comprehend, especially if you need to
references it in several places; like so:

Sub Test()
Lastrow = Range("A65536").End(xlup).row
ActiveSheet.Range("J2","J"&Lastrow).Value=0
End Sub
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Fill handle fill down alternative methods question Rufio Excel Discussion (Misc queries) 1 May 18th 09 04:28 PM
Automatically fill in third column depending on data in second column J.J. Excel Programming 2 May 11th 07 07:34 PM
Fill a column with the contents of another column based on a choic Sparky56 Excel Discussion (Misc queries) 1 March 31st 07 04:18 AM
Excel 2007 column chart fill question Anvah Gareson Charts and Charting in Excel 1 February 3rd 07 06:08 PM
Auto Fill Column with Date based on rows in other column JOUIOUI Excel Programming 2 June 6th 06 06:28 PM


All times are GMT +1. The time now is 01:54 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"