#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Fill Macro


Hi

I am new to macros, and havent any past experience with programming. I
am looking for a way of making a macro that looks for the last row in a
table of three columns, and fills it down a row.

A rough idea of what i want can be found here 'Macro Question'
(http://www.yakery.com/images/macrohelp.png)

Thanks in advance, ben


--
benb7760
------------------------------------------------------------------------
benb7760's Profile: http://www.excelforum.com/member.php...o&userid=24382
View this thread: http://www.excelforum.com/showthread...hreadid=379710

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Fill Macro


Give this a try


Code:
--------------------
Sub FillMacro()
Dim NumRows As Long
NumRows = ActiveSheet.UsedRange.Rows.Count
Range("A" & NumRows & ":C" & NumRows).AutoFill Destination:=Range("A" & NumRows & ":C" & NumRows + 1), Type:=xlFillDefault
End Sub
--------------------


I'm not sure what you mean by "It would be good if it could auto put in
another value from another reference"
Do you want one of the cells Ax, Bx or Cx to have a fixed value?
or depending on what row you are filling into it will pull a value from
somewhere else on the same worksheet or another worksheet in the same
workbook, etc.
What value do you want it to put in?


--
bhofsetz
------------------------------------------------------------------------
bhofsetz's Profile: http://www.excelforum.com/member.php...o&userid=18807
View this thread: http://www.excelforum.com/showthread...hreadid=379710

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Fill Macro


To insert a value into the b and c columns from another cell reference
it would be good if this can be achieved, but it isnt necessary

I have updated the situation slightly, and here is anothe
demonstration: 'Macro Help
(http://www.yakery.com/images/macrohelp2.png)

The last that you sent me appears to be adding rows, but I'm not sur
what it is filling; the rows are blank :

--
benb776
-----------------------------------------------------------------------
benb7760's Profile: http://www.excelforum.com/member.php...fo&userid=2438
View this thread: http://www.excelforum.com/showthread.php?threadid=37971

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Fill Macro


The macro I sent you will find the last used row on your sheet and then
fill down one row from there in columns A, B, and C.
Since your column A has the Month-Year then it will increment that
value.
It appears that your column B and C have numeric values so it will
simply copy that same value into the next row.

Do you want the value that is currently in the Overview section of your
spreadsheet to be filled into column B and C?

If that is the case try this.


Code:
--------------------
Sub FillMacro()
Dim NumRows As Long
NumRows = ActiveSheet.UsedRange.Rows.Count
Range("B" & NumRows & ":B" & NumRows).AutoFill Destination:=Range("B" & NumRows & ":B" & NumRows + 1), Type:=xlFillDefault
Range("C" & NumRows+1) = Range("F6")
Range("D" & NumRows+1) = Range("F7")
End Sub
--------------------


I have modified the positions to reflect the positions of your two
tables in the MacroHelp example you show.

HTH


--
bhofsetz
------------------------------------------------------------------------
bhofsetz's Profile: http://www.excelforum.com/member.php...o&userid=18807
View this thread: http://www.excelforum.com/showthread...hreadid=379710

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Fill Macro


That works exactly how i want it, there is one slight problem, that it
starts filling from row 50, when the current row it should start from
is 16, and because its starting all the way down there, it is not
filling the date because it isnt in the cell above it. Any way to get
it to start filling from row 16, where it needs to ?

If you dont understand: 'Screenshot and annotation'
(http://www.yakery.com/images/macrohelp3.png)

Thanks for all the help so far!


--
benb7760
------------------------------------------------------------------------
benb7760's Profile: http://www.excelforum.com/member.php...o&userid=24382
View this thread: http://www.excelforum.com/showthread...hreadid=379710



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Fill Macro


benb7760,
That is one drawback with the using the UsedRange command the wa
I have in this macro.
If you have ever done something in a row below the bottom of your tabl
(lower than row 15 in this case) it will find that wit
UsedRange.Rows.Count.

A quick and easy work around is to highlight all rows (or at leas
several hundred) starting at the bottom of your table (row 16) the
right clicking and select 'delete' (Don't just use the delete keyboar
button).

This will clear any reminants of activitiy on the lower rows of you
sheet then the macro will run correctly.

I have seen posts which suggest a more robust way to find the las
populated row in the sheet and will check if I can find tha
information

--
bhofset
-----------------------------------------------------------------------
bhofsetz's Profile: http://www.excelforum.com/member.php...fo&userid=1880
View this thread: http://www.excelforum.com/showthread.php?threadid=37971

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Fill Macro


thank you, everything is working fine. If you do find a better way to
find the last row, it'd be great if you could show me how to work it
into the formula. The only problem left now is that the cells that you
showed me how to do automatically:
Range("C" & NumRows + 1) = Range("F6")
Range("D" & NumRows + 1) = Range("F7")
Arent getting the cell formatting that i desire. Is there a way to do
this?

Thanks for all your help!


--
benb7760
------------------------------------------------------------------------
benb7760's Profile: http://www.excelforum.com/member.php...o&userid=24382
View this thread: http://www.excelforum.com/showthread...hreadid=379710

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Fill Macro


If you are always going to be working on the same sheet then the easiest
way to do it would be to preformat the cells with the desired format.

You can also do it programically by adding the following lines

Range("C" & NumRows + 1) = Range("F6")
Range("C" & NumRows + 1).number.format = "$#0.00"
Range("D" & NumRows + 1) = Range("F7")
Range("D" & NumRows + 1).number.format = "$#0.00"

If you want a different number format then I'd suggest recording a
macro and manually changing the numberformat of a number of different
cells and that will give you an idea of how the syntax will look for
various types of numberformats.

To count the number of rows in a specific column you can replace the
NumRows line with the following:

NumRows = Cells(Rows.Count, "B").End(xlUp).Row

This assumes your Dates are in Column B as in your example.

HTH


--
bhofsetz
------------------------------------------------------------------------
bhofsetz's Profile: http://www.excelforum.com/member.php...o&userid=18807
View this thread: http://www.excelforum.com/showthread...hreadid=379710

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
Macro Fill palups Excel Worksheet Functions 2 January 20th 10 04:55 AM
Fill Macro II Mike Excel Worksheet Functions 0 February 6th 09 07:24 PM
Fill Down Macro Lost in Excel Excel Discussion (Misc queries) 7 December 8th 08 10:24 PM
using a macro for a fill Bob Phillips[_6_] Excel Programming 3 July 6th 04 05:37 PM
Fill Macro Mike Fenton Excel Programming 1 August 9th 03 12:10 AM


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

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

About Us

"It's about Microsoft Excel"