Thread: refedit query
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
keepITcool keepITcool is offline
external usenet poster
 
Posts: 2,253
Default refedit query

Terry...


Try following:
the sendkeys is to cancel the normal refedit's reaction to f4...
i've included application.inputbox for demo only :)..


Option Explicit

Private Sub RefEdit1_KeyDown(KeyCode As Integer, ByVal Shift As Integer)
If KeyCode = vbKeyF4 Then
RefEdit1.Text = ToggleAbs(RefEdit1.Text)
SendKeys "~"
End If
End Sub


Private Sub UserForm_Initialize()
Dim r As Range
Set r = Application.InputBox("Demo application.inputbox", _
"Note the use of F4", Type:=8)
Me.RefEdit1 = r.Address(external:=True)
End Sub

Function ToggleAbs(sAddr$)
Dim relStyles, i%
relStyles = Array(xlRelative, xlAbsolute, xlAbsRowRelColumn, _
xlRelRowAbsColumn)
For i = 0 To 3
If sAddr = Application.ConvertFormula(sAddr, xlA1, xlA1, _
relStyles(i)) Then Exit For
Next
ToggleAbs = Application.ConvertFormula(sAddr, xlA1, xlA1, _
relStyles((i + 1) Mod 4))
End Function



keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


"Terry" wrote:

How can I toggle between relative and absolute cell references using
the F4 key after having selected a cell reference from a refedit
control ?

I am unable to find the event in Refedit that will allow me to
use the F4 key. Please see Excel's Goal Seek Set cell: refedit control
box, where you can simply use the F4 key to toggle between all the
absolute and relative
cell references combinations. Any help you can provide will be very
much appreciated.

Rdgs,

Terry