PC Review


Reply
Thread Tools Rate Thread

Columns Reference in VBA after inserting a new column

 
 
Bam
Guest
Posts: n/a
 
      16th Oct 2008
Hi All,

I have a workbook which seems to be ever evolving, and means i often add in
extra columns which throws out the formulas i have within.
Eg: I'm using formulas like this.

ActiveSheet.Range(Cells(4, 7), Cells(myrowcount, 6)).Formula =
"=IF(S4<>"""",""ORD"",IF(L4>(J4+K4),""Yes"",IF(H4<=8,""Yes"",""No"")))"

Each time I add in a new column, it means i have to redo each formula I have.

What's the best way to handle this??

My Column headings don't change, so could I use a "Match("ColumnHeader" type
statement???

Any help would be appreciated.

Thanks..
 
Reply With Quote
 
 
 
 
Bob Phillips
Guest
Posts: n/a
 
      16th Oct 2008
Use defined names to name the columns. So say you name cell L1 as colL. J1
as colJ, K1 as colK, H1 as colH, S1 as colS, then you would use

ActiveSheet.Range(Cells(4, 7), Cells(myrowcount, 6)).FormulaR1C1 = "=IF(R4C"
& colS.column & "<>"""",""ORD"",IF(R4C" & colL.column & "4>(R4C" &
colJ.column & "+R4C" & colK.column & "),""Yes"",IF(R4C" & colH.column &
"<=8,""Yes"",""No"")))"


--
__________________________________
HTH

Bob

"Bam" <(E-Mail Removed)> wrote in message
news:332F3B4E-E271-4576-A25E-(E-Mail Removed)...
> Hi All,
>
> I have a workbook which seems to be ever evolving, and means i often add
> in
> extra columns which throws out the formulas i have within.
> Eg: I'm using formulas like this.
>
> ActiveSheet.Range(Cells(4, 7), Cells(myrowcount, 6)).Formula =
> "=IF(S4<>"""",""ORD"",IF(L4>(J4+K4),""Yes"",IF(H4<=8,""Yes"",""No"")))"
>
> Each time I add in a new column, it means i have to redo each formula I
> have.
>
> What's the best way to handle this??
>
> My Column headings don't change, so could I use a "Match("ColumnHeader"
> type
> statement???
>
> Any help would be appreciated.
>
> Thanks..



 
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
Macro to Inserting Columns and then add column to horizontal total Alex Microsoft Excel Misc 0 17th Feb 2010 11:16 AM
Inserting new columns past the last column The Beverage Outlet- Cahoun GA Microsoft Excel Misc 3 6th Jun 2008 04:56 PM
Maintain Relative Reference After Inserting a Column =?Utf-8?B?TWFyayBULg==?= Microsoft Excel Worksheet Functions 3 4th Jan 2006 04:56 AM
Inserting new column between the columns ram117 Microsoft Excel Programming 8 3rd Dec 2005 05:02 AM
Formulas: Keeping same row/column reference when columns are inser =?Utf-8?B?TWlrZQ==?= Microsoft Excel Misc 5 11th Feb 2005 09:37 PM


Features
 

Advertising
 

Newsgroups
 


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