Is there a way to change a selection of cells which contain relative references to absolute ones without typing “$” in front of the row and column ranges in each cell?
![]() |
Patch reliability is unclear. Unless you have an immediate, pressing need to install a specific patch, don't do it. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |
-
Reference Types (2000)
Home » Forums » AskWoody support » Productivity software by function » MS Excel and spreadsheet help » Reference Types (2000)
- This topic has 20 replies, 5 voices, and was last updated 22 years, 8 months ago.
AuthorTopicWSMichaelRead
AskWoody LoungerAugust 28, 2002 at 1:04 pm #375631Viewing 0 reply threadsAuthorReplies-
WSSammyB
AskWoody LoungerAugust 28, 2002 at 1:18 pm #612103Select the text of the cell(s) in the formula and press F4. Subsequent, F4’s will cycle thru all the absolute/relative possibilities. Whatever text is selected, partially selected, or has the insertion point next to it will be changed. This means that if you type =a1 and press F4, the formula becomes =$A$1. Try it, you’ll
it! –Sam
-
WSMichaelRead
AskWoody LoungerAugust 28, 2002 at 1:44 pm #612123Thanks Sammy, that is a pretty neat trick, but for the amount of cells I needed to convert, it was fairly lenthy. This is what I finally did using VBA (there may be a cleaner way to do it, but, hey, it worked!)
Sub ChangeRefType() Dim cell As Range For Each cell In ThisWorkbook.Sheets("OrderGuide").Range("b58:d410") cell.Formula = Application.ConvertFormula(Formula:=cell.Formula, _ fromreferencestyle:=xlA1, toreferencestyle:=xlA1, toabsolute:=xlAbsolute) Next End Sub
-
WSSammyB
AskWoody Lounger -
WSMichaelRead
AskWoody Lounger -
WSJohnBF
AskWoody Lounger
-
-
-
WSrory
AskWoody LoungerAugust 28, 2002 at 2:42 pm #612142Hi Mike,
If you’re doing a lot of cells, you might find this quicker (sorry it’s a bit late!):Sub ChangeRefType() With Sheets("OrderGuide").Range("b58:d410") .Formula = Application.ConvertFormula(Formula:=.Formula, _ fromreferencestyle:=xlA1, toreferencestyle:=xlA1, toabsolute:=xlAbsolute) End With End Sub
FWIW.
-
WSMichaelRead
AskWoody LoungerAugust 28, 2002 at 6:32 pm #612200True indeed, works faster I believe.
A fairly ingenious person could attach it to the right click cell menu via an add-in install…be fairly cool to use the RangeSelection to change all the selected cells to or from absolute or relative! …although I think I mostly find the need to change them to absolute.
-
WSrory
AskWoody LoungerAugust 29, 2002 at 7:36 am #612340Mike,
Good idea – I shall add it to my (already overcrowded) right-click menu….
[later edit]
For the sake of completeness, I added a popup menu with all four options on it:Sub AbsoluteRef() With Selection .Formula = Application.ConvertFormula(Formula:=.Formula, _ fromreferencestyle:=xlA1, toreferencestyle:=xlA1, toabsolute:=xlAbsolute) End With End Sub Sub RelativeRef() With Selection .Formula = Application.ConvertFormula(Formula:=.Formula, _ fromreferencestyle:=xlA1, toreferencestyle:=xlA1, toabsolute:=xlRelative) End With End Sub Sub AbsColumnRef() With Selection .Formula = Application.ConvertFormula(Formula:=.Formula, _ fromreferencestyle:=xlA1, toreferencestyle:=xlA1, toabsolute:=xlRelRowAbsColumn) End With End Sub Sub AbsRowRef() With Selection .Formula = Application.ConvertFormula(Formula:=.Formula, _ fromreferencestyle:=xlA1, toreferencestyle:=xlA1, toabsolute:=xlAbsRowRelColumn) End With End Sub
FWIW.
-
WSJohnBF
AskWoody Lounger -
WSrory
AskWoody Lounger -
WSJohnBF
AskWoody LoungerAugust 29, 2002 at 4:07 pm #612488 -
WSMichaelRead
AskWoody LoungerAugust 30, 2002 at 12:30 am #612672OK, got my addin up and running to make changes to the cell commandbar. My question is this, is there a better way to undo the changes other than resetting the cell commandbar? In other words, if I gave this to my worst enemy who had made some serious and in-depth changes to his right click menu, when he uninstalled my add-in, all of his changes would be lost. Is there a better way not to make any enemies in this fashion?
-
WSMichaelRead
AskWoody Lounger -
WSrory
AskWoody LoungerAugust 30, 2002 at 7:45 am #612738 -
WSMichaelRead
AskWoody Lounger -
WSrory
AskWoody Lounger -
WSMichaelRead
AskWoody Lounger -
WSJohnBF
AskWoody LoungerAugust 31, 2002 at 8:08 pm #612974I suck at coding, however, here’s a WAG on the Reference Toggle with some documentation. Just works from whatever is in the first selected cell. Incompletely tested.
Sub FormulaRefToggle()
Dim strFCFormula As String
Dim intRef As Integer
Dim rngSel As Range
On Error Resume Next
Set rngSel = Intersect(ActiveSheet.UsedRange, Selection).SpecialCells(xlCellTypeFormulas, 7)
If Not rngSel Is Nothing Then
strFCFormula = Cells(rngSel.Row, rngSel.Column).FormulaR1C1
‘ xlAbsolute 1
‘ xlAbsRowRelColumn 2
‘ xlRelRowAbsColumn 3
‘ xlRelative 4
intRef = 1 + (1 – CInt(InStr(strFCFormula, “R[“) > 0) * 2 – CInt(InStr(strFCFormula, “C[“) > 0)) Mod 4
‘MsgBox ActiveCell.FormulaR1C1 & vbLf & intRef
rngSel.Formula = Application.ConvertFormula(Formula:=rngSel.Formula, _
fromreferencestyle:=xlA1, toreferencestyle:=xlA1, toabsolute:=intRef)
End If
End SubIf there is a function in the first cell in the selection, this sets all formulas to use the same function, which is a major danger since there is no undo with VBA. I need to research Application.ConvertFormula. Please improve!
-
WSrory
AskWoody LoungerSeptember 1, 2002 at 5:01 pm #613188John,
The major problem (or at least the first one I ran into) is that references relative to the same row or column don’t have the [ in them – e.g. RC[2] or R[2]C. The latter seems to be trickier to allow for. For the time being, as I’m swamped at work too, I think I’ll stick with my 4 separate macros! Though you could combine them and pass a parameter to the sub from the Tag of the commandbarcontrol….. -
WSkjktoo
AskWoody LoungerSeptember 1, 2002 at 6:20 pm #613192John, How about this version.
First put this at the top of the module to contain the sub that follows:Private Type KeyboardBytes kbByte(0 To 255) As Byte End Type Dim kbArray As KeyboardBytes Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Long Private Declare Function GetKeyboardState Lib "user32" (kbArray As KeyboardBytes) As Long Private Declare Function SetKeyboardState Lib "user32" (kbArray As KeyboardBytes) As Long Const VK_NUMLOCK As Integer = &H90 Const VK_SHIFT As Integer = &H10 Const VK_CONTROL As Integer = &H11 Const VK_MENU As Integer = &H12 'Alt key Const VK_CAPSLOCK As Integer = &H14
Now here’s the sub. Attach it to a button and run it this way. Hold down control & shift and click the button to get $A$1, just the control key and click gives $A1, just the shift key and click gives A$1, and just a plain click gives A1.
Sub RefSwitcher() Dim ShiftState As Long Dim CntrlState As Long ShiftState = GetKeyState(VK_SHIFT) And 128 CntrlState = GetKeyState(VK_CONTROL) And 128 If ShiftState = 128 And CntrlState = 128 Then With Selection .Formula = Application.ConvertFormula(Formula:=.Formula, _ fromreferencestyle:=xlA1, toreferencestyle:=xlA1, toabsolute:=xlAbsolute) End With ElseIf CntrlState = 128 Then With Selection .Formula = Application.ConvertFormula(Formula:=.Formula, _ fromreferencestyle:=xlA1, toreferencestyle:=xlA1, toabsolute:=xlRelRowAbsColumn) End With ElseIf ShiftState = 128 Then With Selection .Formula = Application.ConvertFormula(Formula:=.Formula, _ fromreferencestyle:=xlA1, toreferencestyle:=xlA1, toabsolute:=xlAbsRowRelColumn) End With Else With Selection .Formula = Application.ConvertFormula(Formula:=.Formula, _ fromreferencestyle:=xlA1, toreferencestyle:=xlA1, toabsolute:=xlRelative) End With End If End Sub
Ken
-
-
-
-
Viewing 0 reply threads -

Plus Membership
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.
Get Plus!
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.
Search Newsletters
Search Forums
View the Forum
Search for Topics
Recent Topics
-
Fixing Windows 24H2 failed KB5058411 install
by
Alex5723
2 hours, 21 minutes ago -
Out of band for Windows 10
by
Susan Bradley
3 hours, 54 minutes ago -
Giving UniGetUi a test run.
by
RetiredGeek
10 hours, 51 minutes ago -
Windows 11 Insider Preview Build 26100.4188 (24H2) released to Release Preview
by
joep517
18 hours, 28 minutes ago -
Microsoft is now putting quantum encryption in Windows builds
by
Alex5723
16 hours, 27 minutes ago -
Auto Time Zone Adjustment
by
wadeer
22 hours, 58 minutes ago -
To download Win 11 Pro 23H2 ISO.
by
Eddieloh
20 hours, 38 minutes ago -
Manage your browsing experience with Edge
by
Mary Branscombe
1 hour, 13 minutes ago -
Fewer vulnerabilities, larger updates
by
Susan Bradley
12 hours, 9 minutes ago -
Hobbies — There’s free software for that!
by
Deanna McElveen
16 hours, 26 minutes ago -
Apps included with macOS
by
Will Fastie
16 hours, 4 minutes ago -
Xfinity home internet
by
MrJimPhelps
15 hours, 59 minutes ago -
Convert PowerPoint presentation to Impress
by
RetiredGeek
15 hours, 57 minutes ago -
Debian 12.11 released
by
Alex5723
1 day, 20 hours ago -
Microsoft: Troubleshoot problems updating Windows
by
Alex5723
1 day, 23 hours ago -
Woman Files for Divorce After ChatGPT “Reads” Husband’s Coffee Cup
by
Alex5723
1 day, 3 hours ago -
Moving fwd, Win 11 Pro,, which is best? Lenovo refurb
by
Deo
19 hours, 38 minutes ago -
DBOS Advanced Network Analysis
by
Kathy Stevens
2 days, 16 hours ago -
Microsoft Edge Launching Automatically?
by
healeyinpa
2 days, 7 hours ago -
Google Chrome to block admin-level browser launches for better security
by
Alex5723
4 hours, 50 minutes ago -
iPhone SE2 Stolen Device Protection
by
Rick Corbett
2 days, 11 hours ago -
Some advice for managing my wireless internet gateway
by
LHiggins
1 day, 19 hours ago -
NO POWER IN KEYBOARD OR MOUSE
by
HE48AEEXX77WEN4Edbtm
21 hours, 9 minutes ago -
A CVE-MITRE-CISA-CNA Extravaganza
by
Nibbled To Death By Ducks
3 days, 4 hours ago -
Sometimes I wonder about these bots
by
Susan Bradley
16 hours, 58 minutes ago -
Does windows update component store “self heal”?
by
Mike Cross
2 days, 15 hours ago -
Windows 11 Insider Preview build 27858 released to Canary
by
joep517
3 days, 18 hours ago -
Pwn2Own Berlin 2025: Day One Results
by
Alex5723
2 days, 2 hours ago -
Windows 10 might repeatedly display the BitLocker recovery screen at startup
by
Susan Bradley
1 day, 15 hours ago -
Windows 11 Insider Preview Build 22631.5409 (23H2) released to Release Preview
by
joep517
3 days, 21 hours ago
Recent blog posts
Key Links
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Mastodon profile for DefConPatch
Mastodon profile for AskWoody
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.