banjoflanjo
New Member
- Joined
- Mar 20, 2008
- Messages
- 44
Hi,
I'm currently using the following code for autofilling a formula via a macro:
Dim rng As Range
Set rng = ActiveSheet.Range("B9")
rng.AutoFill Range(rng, rng.Offset(0, -1).End(xlDown).Offset(0, 1))
Basically, I run a standard weekly report and use a macro to automatically insert formulae, chop up and filter the data as required, and then drop the formatted info into a database. Now the above code has been working great until the last report that I ran. The last report only had one line of data on it for the week, so my macro inserted the formulae against the one line of info, and then tried to fill all of my formulae down to the very last row and caused problems with the rest of my macro from there.
Does anyone know how I can do the same as the code used above, but so that it can also recognise when there is only one line of data and so that it doesn't try to fill down to the very bottom?
Many thanks in advance!
Banjo
I'm currently using the following code for autofilling a formula via a macro:
Dim rng As Range
Set rng = ActiveSheet.Range("B9")
rng.AutoFill Range(rng, rng.Offset(0, -1).End(xlDown).Offset(0, 1))
Basically, I run a standard weekly report and use a macro to automatically insert formulae, chop up and filter the data as required, and then drop the formatted info into a database. Now the above code has been working great until the last report that I ran. The last report only had one line of data on it for the week, so my macro inserted the formulae against the one line of info, and then tried to fill all of my formulae down to the very last row and caused problems with the rest of my macro from there.
Does anyone know how I can do the same as the code used above, but so that it can also recognise when there is only one line of data and so that it doesn't try to fill down to the very bottom?
Many thanks in advance!
Banjo