PC Review


Reply
Thread Tools Rate Thread

Autofill Based on a Changing Column

 
 
sgltaylor
Guest
Posts: n/a
 
      27th Nov 2009
Hi

Any assistance with the following would be most welcome.

I am trying to find some VBA code which will allow me to copy a
formula from an ActiveCell down to the last row in the ActiveCell
column based on the non blank cells in the column to the left of the
ActiveCell column.

For example, if the ActiveCell is equal to C5 and the range B5 to B20
contains entries.
I would like to autofill the formula from cell C5 down to C20.

To further complicate matters, the ActiveCell may be in column C in
one instance and in another it could be column D etc (in other words,
it can be in any column depending on the source data). The column to
the immediate left will always have entries in it but the number of
rows will change as well.

Thanks,

Steve

PS I am using Microsoft Office 2003 with windows XP
 
Reply With Quote
 
 
 
 
OssieMac
Guest
Posts: n/a
 
      27th Nov 2009
Hi Steve,

Hope I have interpreted your question correctly. Ensure that you back up
your data first just in case.

Note that a space and underscore at the end of a line is a line break in an
otherwise single line of code.

Sub CopyPasteFormula()

Dim rngActiveCell As Range
Dim lngRow As Long

Set rngActiveCell = ActiveCell

lngRow = rngActiveCell.Offset(0, -1) _
.End(xlDown).Row

rngActiveCell.Copy _
Destination:=Range(rngActiveCell, _
Cells(lngRow, rngActiveCell.Column))

End Sub

--
Regards,

OssieMac


 
Reply With Quote
 
sgltaylor
Guest
Posts: n/a
 
      27th Nov 2009
On Nov 27, 8:23*pm, OssieMac <Ossie...@discussions.microsoft.com>
wrote:
> Hi Steve,
>
> Hope I have interpreted your question correctly. Ensure that you back up
> your data first just in case.
>
> Note that a space and underscore at the end of a line is a line break in an
> otherwise single line of code.
>
> Sub CopyPasteFormula()
>
> Dim rngActiveCell As Range
> Dim lngRow As Long
>
> Set rngActiveCell = ActiveCell
>
> lngRow = rngActiveCell.Offset(0, -1) _
> * .End(xlDown).Row
>
> rngActiveCell.Copy _
> * Destination:=Range(rngActiveCell, _
> * Cells(lngRow, rngActiveCell.Column))
>
> End Sub
>
> --
> Regards,
>
> OssieMac


A big thank you.
The code worked great.

Cheers,

Steve
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
MS Excel - changing reference column value based on another column Dharmesh Patel Microsoft Excel Misc 2 12th Oct 2009 01:19 PM
Excel - changing column reference based on value of other column Dharmesh Patel Microsoft Excel Misc 2 12th Oct 2009 01:18 PM
RE: Automating to autofill column B based on column A entry Shane Devenshire Microsoft Excel Misc 0 2nd Dec 2008 10:02 PM
Autofill 1 column with changing data and changing range cdclayton Microsoft Excel Programming 0 5th Aug 2008 04:37 PM
Autofill Column D based on input in Column C =?Utf-8?B?SGVsZW4gTWNDbGFpbmU=?= Microsoft Excel Misc 1 5th Apr 2005 09:11 PM


Features
 

Advertising
 

Newsgroups
 


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