Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Relative reference in VB with If Then

Since this is occuring in thousands of rows I would like to automate it with
a macro and leave the formula in a cell that can be modified (if need be) by
the user. So, say it looks like this:
For x = 21 To 2500
If Cells(x, 6) Cells(19,6) Then
Cells(x, 15).Formula = Cells(19,15).Formula
flag = 1
End If
The formula in row19 column15 is this: =IF(AC190,0,IF(D19<"
",IF(B19="X",VLOOKUP(D19,'2006 IP Template'!B:C,2,FALSE),IF(D19<"
",IF(B19="y",VLOOKUP(D19,'2006 IP Template'!B:C,2,FALSE),IF(D19<"
",IF(B19="Z",VLOOKUP(D19,'2006 IP Template'!B:C,2,))))))))
My PROBLEM is I don't know how to make this formula copy down the rows as a
RELATIVE CELL REFERENCE. What code would make this formula change to refer
to row 21 and so on as it gets pasted down?

Your help is most appreciated!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 272
Default Relative reference in VB with If Then

Bill, if '19' only occurs where there is a row in the formula simply do a
replace first:

Cells(x,15).Formula = Replace(Cells(19,15).Formula,19,x)

--
Charles Chickering

"A good example is twice the value of good advice."


"bill ch" wrote:

Since this is occuring in thousands of rows I would like to automate it with
a macro and leave the formula in a cell that can be modified (if need be) by
the user. So, say it looks like this:
For x = 21 To 2500
If Cells(x, 6) Cells(19,6) Then
Cells(x, 15).Formula = Cells(19,15).Formula
flag = 1
End If
The formula in row19 column15 is this: =IF(AC190,0,IF(D19<"
",IF(B19="X",VLOOKUP(D19,'2006 IP Template'!B:C,2,FALSE),IF(D19<"
",IF(B19="y",VLOOKUP(D19,'2006 IP Template'!B:C,2,FALSE),IF(D19<"
",IF(B19="Z",VLOOKUP(D19,'2006 IP Template'!B:C,2,))))))))
My PROBLEM is I don't know how to make this formula copy down the rows as a
RELATIVE CELL REFERENCE. What code would make this formula change to refer
to row 21 and so on as it gets pasted down?

Your help is most appreciated!

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Relative reference in VB with If Then

"Wow wowwy wow wow!!" Thanks this is nice and simple and works perfect.
Absolutely, a good example. Can't thank you enough.

"Charles Chickering" wrote:

Bill, if '19' only occurs where there is a row in the formula simply do a
replace first:

Cells(x,15).Formula = Replace(Cells(19,15).Formula,19,x)

--
Charles Chickering

"A good example is twice the value of good advice."


"bill ch" wrote:

Since this is occuring in thousands of rows I would like to automate it with
a macro and leave the formula in a cell that can be modified (if need be) by
the user. So, say it looks like this:
For x = 21 To 2500
If Cells(x, 6) Cells(19,6) Then
Cells(x, 15).Formula = Cells(19,15).Formula
flag = 1
End If
The formula in row19 column15 is this: =IF(AC190,0,IF(D19<"
",IF(B19="X",VLOOKUP(D19,'2006 IP Template'!B:C,2,FALSE),IF(D19<"
",IF(B19="y",VLOOKUP(D19,'2006 IP Template'!B:C,2,FALSE),IF(D19<"
",IF(B19="Z",VLOOKUP(D19,'2006 IP Template'!B:C,2,))))))))
My PROBLEM is I don't know how to make this formula copy down the rows as a
RELATIVE CELL REFERENCE. What code would make this formula change to refer
to row 21 and so on as it gets pasted down?

Your help is most appreciated!

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
Relative Reference help Barnej75 Excel Discussion (Misc queries) 4 July 3rd 07 02:21 AM
Using an offset formula for the reference in a relative reference Cuda Excel Worksheet Functions 6 November 15th 06 05:12 PM
relative reference Swannybuck Excel Discussion (Misc queries) 1 July 26th 06 09:28 PM
Relative Reference Hari Excel Discussion (Misc queries) 4 October 26th 05 02:00 AM
relative reference Charlie New Users to Excel 3 December 3rd 04 07:22 PM


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

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"