Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 73
Default Autofill VBA Q

I have part of VBA code below that Places "1" in B2; then moves to B3 and inserts a formula, essentially if T30,1, B2+1. It then copies this formuala down to last row, but if last Row is B3 I get an error. How do I get around this?

I've tried replacing B3 with B4 but that just puts a value of 3 in B4 when it should be <blank


Range("B2").Formula = "1"
Range("B3").Select
With Selection
.Formula = "=IF(T30,1,B2+1)"
.AutoFill Destination:=Range("B3:B" & Range("B500").End(xlUp).Row)
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 73
Default Autofill VBA Q

Claus, you saved the day again, thanks

One further twist I've just spotted, if I have only 2 Rows, your Autofill will show 0 in B3, instead of Blank, if I have 3 rows or more its perfect

Note on above A3 is empty

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 73
Default Autofill VBA Q

Can't get my head around this, with formula below, if there is only 2 rows of data (row 1 is header stuff), B2 will = 0 (its embedded with formula =IF(T30,1,B2+1), it should be 1 and B3 = 0, it should be <blank. Note there is a value in A1 & A2, hence the check on Column A

If there are more than 2 rows, formula works perfectly

If I am specifying B2 to be 1 and Autofillng from B3, how can B2 be populated with a formula, if Row2 is the last row of data?



With ActiveSheet
LRow = .Cells(.Rows.Count, "A").End(xlUp).Row
.Range("B2") = 1
.Range("B3:B" & LRow).Formula = "=IF(T30,1,B2+1)"



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 Until uberathlete Excel Discussion (Misc queries) 1 November 10th 05 05:08 PM
Autofill until uberathlete Excel Discussion (Misc queries) 1 November 9th 05 07:01 PM
Autofill? Amateur Excel Discussion (Misc queries) 3 September 9th 05 07:46 PM
Autofill: Need to autofill one week block, (5) weekday only into cells. dstock Excel Discussion (Misc queries) 1 June 17th 05 08:21 PM
Q. Autofill question: Can I autofill alpha characters like I can numbers? George[_22_] Excel Programming 5 August 7th 04 10:33 AM


All times are GMT +1. The time now is 07:42 PM.

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"