Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,388
Default Autofill to Last Row but Miss Some Rows?

Hi Guys,

I'm trying to write in to a macro the ability to Autofill a column from a
cell (H7) to LastRow as you can see below, but miss out rows that have no
value in Column D.

E.g.

If

LastRow is 20
D7 has value? Yes. Fill Row.
D8 has value? Yes. Fill Row.
D9 has value? No. Skip Row.
D10 has value? Yes. Fill Row.........

Code:

Dim lastRow As Long
lastRow = Range("A65536").End(xlUp).row
Range("H7:H7").Select
Selection.AutoFill Destination:=Range("H2:H" & lastRow)
Can anyone help with this?

Thanks
Dave
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 772
Default Autofill to Last Row but Miss Some Rows?

let me know if this does not work for you

Dim lastRow As Long
Dim startRow as Long
Dim strData as String
startRow=2
lastRow = Range("A65536").End(xlUp).row
strData=Range(7,8)
For i=startRow to lastRow
If cells(i+5,4)<"" then cells(i,8)=strData 'if D7 has something H2=H7
Next
--
-John
Please rate when your question is answered to help us and others know what
is helpful.


"Dave" wrote:

Hi Guys,

I'm trying to write in to a macro the ability to Autofill a column from a
cell (H7) to LastRow as you can see below, but miss out rows that have no
value in Column D.

E.g.

If

LastRow is 20
D7 has value? Yes. Fill Row.
D8 has value? Yes. Fill Row.
D9 has value? No. Skip Row.
D10 has value? Yes. Fill Row.........

Code:

Dim lastRow As Long
lastRow = Range("A65536").End(xlUp).row
Range("H7:H7").Select
Selection.AutoFill Destination:=Range("H2:H" & lastRow)
Can anyone help with this?

Thanks
Dave

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
Autofill counting up Columns and Rows! fantomet Excel Worksheet Functions 5 December 14th 06 12:57 PM
Macros or the Fastest way to Autofill Rows klafert Excel Discussion (Misc queries) 1 September 30th 06 09:04 PM
Need help wiht a macro for autofill rows klafert Excel Worksheet Functions 9 September 10th 06 07:47 PM
AutoFill down X number of rows. Paul987 Excel Discussion (Misc queries) 2 April 24th 06 06:36 PM
AutoFill over 30,000 rows Cathy Excel Worksheet Functions 4 January 31st 06 10:22 PM


All times are GMT +1. The time now is 06:13 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"