Excel telling me my blank cells aren't blank - excel
I'm trying to get rid of the blank cells between my cells which have info in them by using F5 to find the blank cells, then Ctrl + - to delete them, and shift the cells up. But when I try to do that, it tells me that there are 'No cells found'.
I've noticed that if I select my 'blank' cells, Excel still counts them: which is weird. But if I press Delete on those selected cells, the count goes away, and then I can go F5, blanks, Ctrl + - and Shift cells up, and it works...
So my question is how can I still do that, but with these blank cells which Excel thinks aren't blank? I've tried to go through and just press delete over the blank cells, but I have a lot of data and realized that it would take me WAY too long. I need to find a way to select these 'blank' cells within a selection of data.
a simple way to select and clear these blank cells to make them blank:
Press ctrl + a or pre-select your range
Press ctrl + f
Leave find what empty and select match entire cell contents.
Hit find all
Press ctrl + a to select all the empty cells found
Close the find dialog
Press backspace or delete
This worked for me:
CTR-H to bring up the find and replace
leave 'Find What' blank
change 'Replace with' to a unique text, something that you are
positive won't be found in another cell (I used 'xx')
click
'Replace All'
copy the unique text in step 3 to 'Find what'
delete the unique text in 'Replace with'
click 'Replace All'
A revelation: Some blank cells are not actually blank! As I will show cells can have spaces, newlines and true empty:
To find these cells quickly you can do a few things.
The =CODE(A1) formula will return a #VALUE! if the cell is truly empty, otherwise a number will return. This number is the ASCII number used in =CHAR(32).
If you select the cell and click in the formula bar and use the cursor to select all.
Removing these:
If you only have a space in the cells these can be removed easily using:
Press ctrl + h to open find and replace.
Enter one space in the find what, leave replace with empty and ensure you have match entire cell contents is ticked in the options.
Press replace all.
If you have newlines this is more difficult and requires VBA:
Right click on the sheet tab > view code.
Then enter the following code. Remember the Chr(10) is a newline only replace this as required, e.g. " " & Char(10) is a space and a newline:
Sub find_newlines()
With Me.Cells
Set c = .Find(Chr(10), LookIn:=xlValues, LookAt:=xlWhole)
If Not c Is Nothing Then
firstAddress = c.Address
Do
c.Value = ""
Set c = .FindNext(c)
If c Is Nothing Then Exit Do
Loop While c.Address <> firstAddress
End If
End With
End Sub
Now run your code pressing F5.
After file supplied: Select the range of interest for improved performance, then run the following:
Sub find_newlines()
With Selection
Set c = .Find("", LookIn:=xlValues, LookAt:=xlWhole)
If Not c Is Nothing Then
firstAddress = c.Address
Do
c.Value = ""
Set c = .FindNext(c)
If c Is Nothing Then Exit Do
Loop While c.Address <> firstAddress
End If
End With
End Sub
All, this is pretty simple. I have been trying for the same and this is what worked for me in VBA
Range("A1:R50").Select 'The range you want to remove blanks
With Selection
Selection.NumberFormat = "General"
.Value = .Value
End With
Regards,
Anand Lanka
I had a similar problem where scattered blank cells from an export from another application were still showing up in cell counts.
I managed to clear them by
Selecting the columns/rows I wanted to clean, then doing
"Find" [no text] and "Replace" [word of choice].
Then I did "Find" [word of choice] and "Replace" with [no text].
It got rid of all hidden/phantom characters in those cells. Maybe this will work for you?
If you don't have formatting or formulas you want to keep, you can try saving your file as a tab delimited text file, closing it, and reopening it with excel. This worked for me.
Not sure if this has already been said, but I had a similar problem with cells showing nothing in them, but not being blank when you run the IsBlank() formula.
I selected the entire column, selected Find & Replace, found cells with nothing and replaced with a 0, then ran find and replace again, finding cells with 0 and replacing with "".
This solved my problem and allowed me to search for Blank cells (F5, Special, Blanks) and delete rows that were blank....BOOM.
May not work for every application but this solved my problem.
Sometimes there are spaces in cells which appear blank but if you hit F2 on the cell, you'll see spaces. You can also search this way if you know the exact number of spaces in a cell
The most simple solution for me has been to:
1)Select the Range and copy it (ctrl+c)
2)Create a new text file (anywhere, it will be deleted soon), open the text file and then paste in the excel information (ctrl+v)
3)Now that the information in Excel is in the text file, perform a select all in the text file (ctrl+a), and then copy (ctrl+c)
4)Go to the beginning of the original range in step 1, and paste over that old information from the copy in step 3.
DONE! No more false blanks! (you can now delete the temp text file)
'Select non blank cells
Selection.SpecialCells(xlCellTypeConstants, 23).Select
' REplace tehse blank look like cells to something uniqu
Selection.Replace What:="", Replacement:="TOBEDELETED", LookAt:=xlWhole, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
'now replace this uique text to nothing and voila all will disappear
Selection.Replace What:="TOBEDELETED", Replacement:="", LookAt:=xlWhole, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Found another way. Set AutoFilter for all columns (important or you will misalign data) by selecting the header row > 'Data' tab > Sort and filter - 'Filter'. Use drop-down in first data column, untick 'Select all' and select only '(Blanks)' option > [OK]. Highlight rows (now all together) > right click > 'Delete row'. Head back to the drop-down > 'Select all'. Presto :)
This works with numbers.
If your range is O8:O20, then in a nearby empty range (e.g. T8:T20) enter =O8/1 and fill down. This will give you a result of #VALUE for the 'empty' cells and your original number will remain as it was.
Then with the range T8:20 selected (CTL-* if it's not already) hit F5 and choose Special. From the Special dialogue, choose Errors and click OK. This will deselect your actual numbers leaving only the #VALUE cells selected. Delete them and you will have actual empty cells. Copy T8:T20 and paste back over O8:O20.
Essentially, since blank cells doesn't work, you need to convert the 'empty' cells into something that the Go To Special can latch on to. Any action that would convert into #VALUE would work, and other 'error' types should be supported as well.
My method is similar to Curt's suggestion above about saving it as a tab-delimited file and re-importing.
It assumes that your data has only values without formulas.
This is probably a good assumption because the problem of "bad" blanks is caused by the confusion between blanks and nulls -- usually in the data imported from some other place -- so there shouldn't be any formulas.
My method is to parse in place -- very similar to saving as a text file and re-importing, but you can do this without closing and re-opening the file.
It's under Data > Text-to-Columns > delimited > remove all parsing characters (can also choose Text if you want) > Finish. This should cause Excel to re-recognize your data from scratch or from text and recognize blanks as really blank.
You can automate this in a subroutine:
Sub F2Enter_new()
Dim rInput As Range
If Selection.Cells.Count > 1 Then Set rInput = Selection
Set rInput = Application.InputBox(Title:="Select", prompt:="input range", _
Default:=rInput.Address, Type:=8)
' Application.EnableEvents = False: Application.ScreenUpdating = False
For Each c In rInput.Columns
c.TextToColumns Destination:=Range(c.Cells(1).Address), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=False, _
Semicolon:=False, Comma:=False, Space:=False, Other:=False, _
FieldInfo:=Array(1, 1), TrailingMinusNumbers:=True
Next c
Application.EnableEvents = True: Application.ScreenUpdating = True
End Sub
You can also turn-on that one commented line to make this subroutine run "in the background". For this subroutine, it improves performance only slightly (for others, it can really help a lot).
The name is F2Enter because the original manual method for fixing this "blanks" problem is to make Excel recognize the formula by pushing F2 and Enter.
Here's how I fixed this problem without any coding.
Select the entire column that I wanted to delete the "blank" cells from.
Click the Conditional Formatting tab up top.
Select "New Rule".
Click "Format only cells that contain".
Change "between" to "equal to".
Click the box next to the "equal to" box.
Click one of the problem "blank" cells.
Click the Format Button.
Pick a random color to fill the box with.
Press "OK".
This should change all of the problem "blank" cells to the color that you chose. Now Right click one of the colored cells, and go to "Sort" and "Put selected cell color on top".
This will put all of the problem cells at the top of the column and now all of your other cells will stay in the original order you put them in. You can now select all of the problem cells in one group and click the delete cell button on top to get rid of them.
Goto->Special->blanks does not like merged cells. Try unmerging cells above the range in which you want to select blanks then try again.
I had a similar problem with getting the COUNTA formula to count non-blank cells, it was counting all of them (even the blank one's as non-blank), I tried =CODE() but they had no spaces or new lines.
I found that when I clicked in the cell and then clicked out of it then the formula would count the cell. I had thousands of cells so could not do this manually. I wrote this VBA statement to literally check all the cells and if they were blank then to make them blank. Ignore the pointlessness of this macro and trust me that it actually worked by forcing Excel to recognize the empty cells as actually being empty.
'This checks all the cells in a table so will need to be changed if you're using a range
Sub CreateBlanks()
Dim clientTable As ListObject
Dim selectedCell As Range
Set clientTable = Worksheets("Client Table").ListObjects("ClientTable")
For Each selectedCell In clientTable.DataBodyRange.Cells
If selectedCell = "" Then
selectedCell = ""
End If
Next selectedCell
End Sub
Save your dataset in CSV file and open that file and copy the dataset and paste to the excel file.
and then crtl + g will work on your file, means the excel will recognize that blank is really blank.
Related
Excel Functions Not Working on Imported File
I have a .CSV which I imported into Excel using Data > From Text/CSV and selected semi-colon as my delimiter. The data looks fine. When I attempt to sum(), countif(), etc on a range I get "0". I have attempted: Select all, format as numbers Select all, copy, paste special - numbers only, on a new sheet Save as .xlsx and reopen Open new sheet, =sheet1!A1 and copy everything None of this has worked. Clue: The numbers were imported centered to the left of each cell. If I select a cell with a number, cursor to the number in the fx bar, hit enter, the number then shifts to the right of the cell and functions work just fine.
Try fixing your import. Sub fixTextThatLookLikeNumbers() dim i as long with worksheets(1) for i=.cells(1, .columns.count).emd(xltoleft).column to 1 step -1 with .columns(i) .texttocolumns destination:=.cells(1), _ datatype:=xlfixedwidth, fieldinfo:=array(0,1) end with next i end sub end sub
Delete blank cells in range
I want to delete blank cells in a range (E1:E130). This code skips cells. For Each cell In ranger If cell.Value = "" Then cell.Delete End If next cell To make my objective more clear: I have a list of cells with text and empty cells in the range E1:E130 and I want to make a list starting on E1 without any empty cells. Sorting on alphabet for instance would also be a good solution, however that didn't work out for me either.
I'd go like follows With Range("E1:E130") If WorksheetFunction.CountA(.Cells) > 0 Then .SpecialCells(xlCellTypeBlanks).Delete Shift:=xlShiftUp End With
You could use the Range.SpecialCells Method to delete all blank cells in a specific range at once: Range("E1:E130").SpecialCells(xlCellTypeBlanks).Delete
You can try with this code to remove blank cell on define range : Sub RemoveBlankCells() Dim rng As Range 'Store blank cells inside a variable On Error GoTo NoBlanksFound Set rng = Range("E1:E130").SpecialCells(xlCellTypeBlanks) On Error GoTo 0 'Delete blank cells and shift upward rng.Rows.Delete Shift:=xlShiftUp Exit Sub 'ERROR HANLDER NoBlanksFound: MsgBox "No Blank cells were found" End Sub
Necromancing an old question here, but: OP, I'm not sure your issue (of the 'for each cell in range' not deleting all the wanted cells) stems from the following, but before I knew about Range(...).RemoveDuplicates, i wrote 'for loops' for that very task. At first i ran the loop from top to bottom and removed the unwanted cells. But when you remove a cell, the whole column shifts up, while your counter stays on the same value, so if there were 2 blank, the second one was shifted up when removing the first, and then the loop jumped over the blank. So I, then, ran the loop bottom to top (step -1), and that took care of this issue.
This should work: Columns("E:E").Select Selection.SpecialCells(xlCellTypeBlanks).Select Selection.Delete Shift:=xlUp
This one uses special methods and is more useful if you wanna erase all the data associated with the blank cells. Range("A:B").SpecialCells(xlCellTypeBlanks).Select Selection.EntireRow.Delete
Excel VBA Index Match Only Blank Row [duplicate]
So I have a column with blanks randomly throughout...I need a macro that would select only the blanks, and then in those blank cells paste in the value of the cell above it. The select part is obviously easy, but I keep getting errors about 'too many continuations' when trying to fill the formula down into the blanks. I included a picture, the first column is a 'before' and the second is how I want the column to look after the application of the macro. If the macro needs to create a second column or something that's fine too, as long as the end result looks like it does in the picture. Thanks! Picture to illustrate.
try, sub fillblankfromabove() dim blnks as range with worksheets("Sheet1").Columns("E").Cells set blnks = .specialcells(xlcelltypeblanks) if not blnks is nothing then blnks.formular1c1 = "=r[-1]c" end if .value = .value end with end sub
Another way to do this is to select all cells that you want included in this process, press CTRL + G, select Special, then select 'Blank Cells'. This will select all blank cells within your selected range. Then enter =[cell above] and press CTRL + ENTER and it will enter that formula into all selected cells.
Excel cells from Access export look empty but are not (=isblank=FALSE)
My problem is that an Excel spreadsheet (exported from Access as .xls) has cells that look empty, but are not. This is mucking up my calculations & navigation shortcuts. There are no formulae or contents in the cells (the answers already posted on this topic don't fix my problem). I've attached an image of my problem (see bottom) Troubleshooting shows: If I test these cells e.g. =isblank(a1), it's FALSE. The cell lengnth is 0, according to =LEN(a1) If I try 'Go to (special) highlight "Blanks" (or any other go to special combination like formula/text,numbers, etc) it will NOT highlight these empty looking cells YET if I filter the column, I can select these non-empty "blanks" from the filter list (this is the only way to identify these tricky cells I've found so far) - So my column has entries in some cells, "blank" non-empty cells. I only want the cells with entries, the rest I need cleared. This also annoyingly means the shortcut to skip to the next empty or nonempty cell wont work (it reads all as nonblank) - making it super painful to navigate the large dataset. Once I click within an individual 'non-empty' blank cell & press enter, this seems to clear the cell contents ('=isblank' formula's that were saying "FALSE" now switch to 'TRUE') - this is not feasible to fix individual cells in such a large dataset though. Can ANYONE help?! I have found 2 basic workarounds that fix this, but I really want to know how & why this happens & how to avoid it in future. Workaround 1 In excel, filter the column, show only "blank", then highlight the filtered column & press delete. Unfilter the list & the problems solved. Workaround 2 save the excel spreadsheet from 'file.xlsx' & save as '.csv'. Close it all, open the csv & it seems the non-empty blank cells are fixed, show =isblank= TRUE & can be skipped with [CNTL arrow key] shortcuts now. This is so frustrating & I haven't seen any similar questions nor answers on why this is? Why is this happening & are there any other fixes around for this? Thanks hive-mind! excel sheet shows non-blank empty cells - working
Sometimes it's nice to have the ctrl+up/down stop at the edge of the data set other times it's not; here's the macro I use to clear the selected range's "blank" cells for when it's not: 'clears cells with error or empty string values Public Sub clearJunk() Dim scrn As Boolean: scrn = Application.ScreenUpdating: Application.ScreenUpdating = False Dim i As Long, rowCount As Long, FirstRow As Long Dim col As Range rowCount = Selection.Columns(1).Cells.count FirstRow = Selection.Cells(1).Row - 1 For Each col In Selection.Columns For i = 1 To rowCount If IsEmpty(col.Cells(i)) Then i = col.Cells(i).End(xlDown).Row - FirstRow If i > rowCount Then Exit For If IsError(col.Cells(i).Value) Then col.Cells(i).ClearContents ElseIf col.Cells(i).Value = "" Then col.Cells(i).ClearContents ElseIf Trim(col.Cells(i).Value) = "" Then col.Cells(i).ClearContents End If Next i Next col Application.ScreenUpdating = scrn End Sub Also if you're copying and pasting from MS-Access you might find this one useful too: Public Sub UnWrapText(): Selection.WrapText = False: End Sub I've bound both to buttons on my Ribbon/QAT and it's made my life more hassle free.
You can also try the below: Select your region. In the "Find & Replace" dialog box, leave the "Find what:" box empty. Enter any value that doesn't exist yet in your data, e.g. a pipe ("|") in the "Replace with:" box. Check the "Match entire cell contents" option. "Replace All" Now, enter the pipe in the "Find what:" box, and clear the "Replace with:" box. "Replace All", and you're done! Source: https://www.mrexcel.com/board/threads/how-to-remove-null-string-from-cells.565955/ (A bit updated by me)
Just save you excel file as an csv file. Then create in Access a linked table to the csv file. When you create a query to import your data then values which look empty in excel will have a NULL value in Access.
How to disable Excel's automatic cell reference change after copy/paste?
I've got a massive Excel 2003 spreadsheet I'm working on. There are a lot of very large formulas with a lot of cell references. Here's a simple example. ='Sheet'!AC69+'Sheet'!AC52+'Sheet'!AC53)*$D$3+'Sheet'!AC49 Most of them are more complicated than that, but this gives a good idea of what I'm working with. Few of these cell references are absolute ($s). I'd like to be able to copy these cells to a different location without the cell references changing. I know I can simply use f4 to make the references absolute, but there is a lot of data and I may need to use Fill later. Is there any way to temporarily disable the cell reference changing on copy-paste/fill without making the references absolute? EDIT: I just found out that you can do this with VBA by copying the cell contents as text instead of a formula. I'd like to not have to do this though because I want to copy whole rows/columns at once. Is there a simple solution I am missing?
From http://spreadsheetpage.com/index.php/tip/making_an_exact_copy_of_a_range_of_formulas_take_2: Put Excel in formula view mode. The easiest way to do this is to press Ctrl+` (that character is a "backwards apostrophe," and is usually on the same key that has the ~ (tilde). Select the range to copy. Press Ctrl+C Start Windows Notepad Press Ctrl+V to past the copied data into Notepad In Notepad, press Ctrl+A followed by Ctrl+C to copy the text Activate Excel and activate the upper left cell where you want to paste the formulas. And, make sure that the sheet you are copying to is in formula view mode. Press Ctrl+V to paste. Press Ctrl+` to toggle out of formula view mode. Note: If the paste operation back to Excel doesn't work correctly, chances are that you've used Excel's Text-to-Columns feature recently, and Excel is trying to be helpful by remembering how you last parsed your data. You need to fire up the Convert Text to Columns Wizard. Choose the Delimited option and click Next. Clear all of the Delimiter option checkmarks except Tab. Or, from http://spreadsheetpage.com/index.php/tip/making_an_exact_copy_of_a_range_of_formulas/: If you're a VBA programmer, you can simply execute the following code: With Sheets("Sheet1") .Range("A11:D20").Formula = .Range("A1:D10").Formula End With
A very simple solution is to select the range you wish to copy, then Find and Replace (Ctrl + h), changing = to another symbol that is not used in your formula (e.g. #) - thus stopping it from being an active formula. Then, copy and paste the selected range to it's new location. Finally, Find and Replace to change # back to = in both the original and new range, thus restoring both ranges to being formulae again.
I came to this site looking for an easy way to copy without changing cell references. But now I thnk my own workaround is simpler than most of these methods. My method relies on the fact that Copy changes references but Move doesn't. Here's a simple example. Assume you have raw data in columns A and B, and a formula in C (e.g. C=A+B) and you want the same formula in column F but Copying from C to F leads to F=D+E. Copy contents of C to any empty temporary column, say R. The relative references will change to R=P+Q but ignore this even if it's flagged as an error. Go back to C and Move (not Copy) it to F. Formula should be unchanged so F=A+B. Now go to R and copy it back to C. Relative reference will revert to C=A+B Delete the temporary formula in R. Bob's your uncle. I've done this with a range of cells so I imagine it would work with virtually any level of complexity. You just need an empty area to park the coiped cells. And of course you have to remember where you left them.
This simple trick works: Copy and Paste. Do NOT cut and paste. After you paste, then reselect the part you copied and go to EDIT, slide down to CLEAR, and CLEAR CONTENTS.
Simple workaround I used just now while in a similar situation: Make a duplicate of the worksheet. Cut + Paste the cells with formulas from the duplicate worksheet (e.g. Copy of Sheet1) into the original worksheet. Remove all occurrences of the the duplicate sheet's name from the newly pasted formulas; e.g. find-and-replace all occurrences of the search term 'Copy of Sheet1'! with an empty string (i.e. blank). Delete duplicate worksheet to clean up. Note: if your sheet name lacks spaces you won't need to use the single quote/apostrophe ('). Your cell references are now copied without being altered.
I think that you're stuck with the workaround you mentioned in your edit. I would start by converting every formula on the sheet to text roughly like this: Dim r As Range For Each r In Worksheets("Sheet1").UsedRange If (Left$(r.Formula, 1) = "=") Then r.Formula = "'ZZZ" & r.Formula End If Next r where the 'ZZZ uses the ' to signify a text value and the ZZZ as a value that we can look for when we want to convert the text back to being a formula. Obviously if any of your cells actually start with the text ZZZ then change the ZZZ value in the VBA macro to something else When the re-arranging is complete, I would then convert the text back to a formula like this: For Each r In Worksheets("Sheet1").UsedRange If (Left$(r.Formula, 3) = "ZZZ") Then r.Formula = Mid$(r.Formula, 4) End If Next r One real downside to this method is that you can't see the results of any formula while you are re-arranging. You may find that when you convert back from text to formula that you have a slew of #REF errors for example. It might be beneficial to work on this in stages and convert back to formulas every so often to check that no catastrophes have occurred
It's common to use find/ replace to disable formulas whilst performing manipulations. For example, copy with transpose. The formula is disabled by placing some placeholder (e.g. "$=") in front of it. Find replace can get rid of these once the manipulation is complete. This vba just automates the find/ replace for the active sheet. ' toggle forumlas on active sheet as active/ inactive ' by use of "$=" prefix Sub toggle_active_formulas() Dim current_calc_method As String initial_calc_method = Application.Calculation Application.Calculation = xlCalculationManual Dim predominant As Integer Dim c As Range For Each c In ActiveSheet.UsedRange.Cells If c.HasFormula Then predominant = predominant + 1 ElseIf "$=" = Left(c.Value, 2) Then predominant = predominant - 1 End If Next c If predominant > 0 Then For Each c In ActiveSheet.UsedRange.Cells On Error Resume Next If c.HasFormula Then c.Value = "$" & c.Formula End If Next c Else For Each c In ActiveSheet.UsedRange.Cells On Error Resume Next If "$=" = Left(c.Value, 2) Then c.Formula = Right(c.Value, Len(c.Value) - 1) End If Next c End If Application.Calculation = initial_calc_method End Sub
This macro does the whole job. Sub Absolute_Reference_Copy_Paste() 'By changing "=" in formulas to "#" the content is no longer seen as a formula. ' C+S+e (my keyboard shortcut) Dim Dummy As Range Dim FirstSelection As Range Dim SecondSelection As Range Dim SheetFirst As Worksheet Dim SheetSecond As Worksheet On Error GoTo Whoa Application.EnableEvents = False ' Set starting selection variable. Set FirstSelection = Selection Set SheetFirst = FirstSelection.Worksheet ' Reset the Find function so the scope of the search area is the current worksheet. Set Dummy = Worksheets(1).Range("A1:A1").Find("Dummy", LookIn:=xlValues) ' Change "=" to "#" in selection. Selection.Replace What:="=", Replacement:="#", LookAt:=xlPart, _ SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False ' Select the area you want to paste the formulas; must be same size as original selection and outside of the original selection. Set SecondSelection = Application.InputBox("Select a range", "Obtain Range Object", Type:=8) Set SheetSecond = SecondSelection.Worksheet ' Copy the original selection and paste it into the newly selected area. The active selection remains FirstSelection. FirstSelection.Copy SecondSelection ' Restore "=" in FirstSelection. Selection.Replace What:="#", Replacement:="=", LookAt:=xlPart, _ SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False ' Select SecondSelection. SheetSecond.Activate SecondSelection.Select ' Restore "=" in SecondSelection. Selection.Replace What:="#", Replacement:="=", LookAt:=xlPart, _ SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False ' Return active selection to the original area: FirstSelection. SheetFirst.Activate FirstSelection.Select Application.EnableEvents = True Exit Sub Whoa: ' If something goes wrong after "=" has been changed in FirstSelection, restore "=". FirstSelection.Select Selection.Replace What:="#", Replacement:="=", LookAt:=xlPart, _ SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False End Sub Note that you must match the size and shape of the original selection when you make your new selection.
I found this solution which automates #Alistair Collins solution. Basically you will change the = in any formula to * then do the paste after that you will change it back Dim cell As Range msgResult = MsgBox("Yes to lock" & vbNewLine & "No unlock ", vbYesNoCancel + vbQuestion, "Forumula locker") If msgResult = vbNo Then For Each cell In Range("A1:i155") If InStr(1, cell.Value, "*") > 0 Then cell.Formula = Replace(cell.Formula, "*", "=") End If Next cell ElseIf msgResult = vbYes Then For Each cell In Range("A1:i155") If cell.HasFormula = True Then cell.Formula = Replace(cell.Formula, "=", "*") End If Next cell End If
Try this: Left-click the tab, making a copy of the whole sheet, then cut the cells you want to keep the same and paste them into your original worksheet.
I found another workaround that is very simple: 1. Cut the contents 2. Paste them in the new location 3. Copy the contents that you just pasted into the new location you want. 4. Undo the Cut-Paste operation, putting the original contents back where you got them. 5. Paste the contents from the clipboard to the same location. These contents will have the original references. It looks like a lot, but is super fast with keyboard shortcuts: 1. Ctrl-x, 2. Ctrl-v, 3. Ctrl-c, 4. Ctrl-z, 5. Ctrl-v
Haven't check in Excel, but this works in Libreoffice4: The whole thing of address rewriting comes during consecutive (a1) cut (a2) paste You need to interrupt the consecutiveness by putting something in-between: (b1) cut (b2) select some empty cells (more than 1) and drag(move) them (b3) paste Step (b2) is where the cell that is about to update itself stops the tracking. Quick and simple.
Click on the cell you want to copy. In the formula bar, highlight the formula. Press Ctrl C. Press escape (to take you out of actively editing that formula). Choose new cell. Ctrl V.