Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default relative address in validate

HI.
with this code I put the formula in B1 with absolute reference to cell A1:

Range("B1").Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:=
_
xlBetween, Formula1:="=A1"
...
...
End With

..

Is possible by vba insert a relative address?
If I use

formular1c1:="RC[-1]"

the code doesn't word.

Any help will be appreciated.
Best rgds
M.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default relative address in validate

How about this?


Range("K1").Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, _
AlertStyle:=xlValidAlertStop, _
Operator:=xlBetween, _
Formula1:="=" & ColumnLetter(ActiveCell.Column - 1) &
ActiveCell.Row
....
....
End With

'-----------------------------------------------------------------
Function ColumnLetter(Col As Long)
'-----------------------------------------------------------------
Dim sColumn As String
sColumn = Split(Columns(Col).Address(, False), ":")(1)
ColumnLetter = sColumn
End Function



--

HTH

RP
(remove nothere from the email address if mailing direct)


"miro" wrote in message
...
HI.
with this code I put the formula in B1 with absolute reference to cell A1:

Range("B1").Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop,

Operator:=
_
xlBetween, Formula1:="=A1"
...
...
End With

.

Is possible by vba insert a relative address?
If I use

formular1c1:="RC[-1]"

the code doesn't word.

Any help will be appreciated.
Best rgds
M.




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default relative address in validate

MMM.. thanks Bob, but the formula in validate is more complicated.

Formula1:= "=OFFSET($AA$11,MATCH( D10
,$AA$11:$AA$106),0):OFFSET($AA$11,95,0)"

I need that D10 is not absolute but relative (2 columns left from cell where
the formula is put)

Thanks
M.


"Bob Phillips" ha scritto nel messaggio
...
How about this?


Range("K1").Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, _
AlertStyle:=xlValidAlertStop, _
Operator:=xlBetween, _
Formula1:="=" & ColumnLetter(ActiveCell.Column - 1) &
ActiveCell.Row
...
...
End With

'-----------------------------------------------------------------
Function ColumnLetter(Col As Long)
'-----------------------------------------------------------------
Dim sColumn As String
sColumn = Split(Columns(Col).Address(, False), ":")(1)
ColumnLetter = sColumn
End Function



--

HTH

RP
(remove nothere from the email address if mailing direct)


"miro" wrote in message
...
HI.
with this code I put the formula in B1 with absolute reference to cell
A1:

Range("B1").Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop,

Operator:=
_
xlBetween, Formula1:="=A1"
...
...
End With

.

Is possible by vba insert a relative address?
If I use

formular1c1:="RC[-1]"

the code doesn't word.

Any help will be appreciated.
Best rgds
M.







  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default relative address in validate

Same principle applies,

"=OFFSET($AA$11,MATCH( & ColumnLetter(ActiveCell.Column - 2) &
ActiveCell.Row
& ",$AA$11:$AA$106),0):OFFSET($AA$11,95,0)"


--

HTH

RP
(remove nothere from the email address if mailing direct)


"miro" wrote in message
...
MMM.. thanks Bob, but the formula in validate is more complicated.

Formula1:= "=OFFSET($AA$11,MATCH( D10
,$AA$11:$AA$106),0):OFFSET($AA$11,95,0)"

I need that D10 is not absolute but relative (2 columns left from cell

where
the formula is put)

Thanks
M.


"Bob Phillips" ha scritto nel

messaggio
...
How about this?


Range("K1").Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, _
AlertStyle:=xlValidAlertStop, _
Operator:=xlBetween, _
Formula1:="=" & ColumnLetter(ActiveCell.Column - 1) &
ActiveCell.Row
...
...
End With

'-----------------------------------------------------------------
Function ColumnLetter(Col As Long)
'-----------------------------------------------------------------
Dim sColumn As String
sColumn = Split(Columns(Col).Address(, False), ":")(1)
ColumnLetter = sColumn
End Function



--

HTH

RP
(remove nothere from the email address if mailing direct)


"miro" wrote in message
...
HI.
with this code I put the formula in B1 with absolute reference to cell
A1:

Range("B1").Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop,

Operator:=
_
xlBetween, Formula1:="=A1"
...
...
End With

.

Is possible by vba insert a relative address?
If I use

formular1c1:="RC[-1]"

the code doesn't word.

Any help will be appreciated.
Best rgds
M.









  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default relative address in validate

Thank you Bob!
In the night (I'm write from Italy) I've found another simply way:

Formula1:= "=OFFSET($AA$11,MATCH(" & ActiveCell.Offset(, -2).Address &
",$AA$11:$AA$106),0):OFFSET($AA$11,95,0)"

Bye
M.


"Bob Phillips" ha scritto nel messaggio
...
Same principle applies,

"=OFFSET($AA$11,MATCH( & ColumnLetter(ActiveCell.Column - 2) &
ActiveCell.Row
& ",$AA$11:$AA$106),0):OFFSET($AA$11,95,0)"


--

HTH

RP
(remove nothere from the email address if mailing direct)


"miro" wrote in message
...
MMM.. thanks Bob, but the formula in validate is more complicated.

Formula1:= "=OFFSET($AA$11,MATCH( D10
,$AA$11:$AA$106),0):OFFSET($AA$11,95,0)"

I need that D10 is not absolute but relative (2 columns left from cell

where
the formula is put)

Thanks
M.


"Bob Phillips" ha scritto nel

messaggio
...
How about this?


Range("K1").Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, _
AlertStyle:=xlValidAlertStop, _
Operator:=xlBetween, _
Formula1:="=" & ColumnLetter(ActiveCell.Column - 1) &
ActiveCell.Row
...
...
End With

'-----------------------------------------------------------------
Function ColumnLetter(Col As Long)
'-----------------------------------------------------------------
Dim sColumn As String
sColumn = Split(Columns(Col).Address(, False), ":")(1)
ColumnLetter = sColumn
End Function



--

HTH

RP
(remove nothere from the email address if mailing direct)


"miro" wrote in message
...
HI.
with this code I put the formula in B1 with absolute reference to cell
A1:

Range("B1").Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop,
Operator:=
_
xlBetween, Formula1:="=A1"
...
...
End With

.

Is possible by vba insert a relative address?
If I use

formular1c1:="RC[-1]"

the code doesn't word.

Any help will be appreciated.
Best rgds
M.











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 address or reference James C. Excel Worksheet Functions 1 July 23rd 09 05:37 AM
How to validate email address during data entry in Excel Ramiro Excel Discussion (Misc queries) 1 January 20th 09 08:30 PM
Validate Email address entry Rayasiom Excel Discussion (Misc queries) 2 May 31st 07 10:36 AM
How do I avoid excel change absolute address to relative address Miguel Excel Discussion (Misc queries) 3 May 10th 07 11:18 PM
what is difference between absolute address and relative address? what is difference between absolute addr Excel Discussion (Misc queries) 1 July 22nd 06 08:17 AM


All times are GMT +1. The time now is 11:40 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"