Thread: refedit query
View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Terry Terry is offline
external usenet poster
 
Posts: 4
Default refedit query

Thanks keepitcool. Your suggestion solves the problem.

In your example, using the application.inputbox method, the screen does not
flash when you toggle the absolute/relative address with the F4 key,
resulting in a very smooth display. In the refedit control, you can see the
quick flashing of the screen when the SendKeys is used to close that floater
screen. Is there any way round this problem ?

Rdgs,

Terry


"keepitcool" wrote in message
...
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