Preserve Formatting When Pasting Into A Cell

Feb 24, 2010

I am making template and trying to preserve formatting when users paste into a cell. From my research, I have found that this is impossible with simple format protection, it works to prevent changing formating, but if something is pasted (with normal paste), the format will change.

I have found a few solutions, but can't get them to work correctly

Solution A: Disable normal paste and substitute Paste Special - Values

How will this work with pasting via CTRL + V and the right click menu? I need both to function.

Solution B: Allow users to paste normally, but use a macro to copy formatting from a hidden sheet

I actually found code for this, but I couldn't figure out exactly how to impliment it. The sheet that users will be pasting into is called "Batch Summary" and I was trying to pull formatting from a sheet names "Batch Summary Format", but was getting an error.

View 9 Replies


Preserve Formatting When Pasting Part Of A Cell

Jun 4, 2013

Is it possible to preserve original text formatting when copying and pasting only part of a cell. Like, for example, a cell may contain ten words one of which is in red and underlined. How do you copy that one word and paste it in another cell so that it remains in red and underlined?

View 4 Replies View Related

ADO ADODB.Connection: Preserve Cell Formatting

Oct 4, 2006

With ADO (ADODB.Connection), is there a way to preserve the cell formatting on the worksheet that the recordset data is copied to? Right now, if I format a Cell's font and font-size, then run the Macro to refresh the data, the formatting is gone and it's back to default formatting.

View 2 Replies View Related

Preserve Formatting In PivotTable

Sep 18, 2007

I have made a pivot table and in Pivot table option Merge labels for colum b. I the problem i am facing is once i give this the next colum text filed is automatically arranged in center. I want the next colum as left alignment. Once i delete some rows in the data then if i refresh it automatically align the next colum to center. I have given the preserve formatting as well as i have un selected the autoformat colum.

View 2 Replies View Related

Preserve Formatting After XML Import

Jun 11, 2008

I have programmed a button that allows the user to import XML data into my workbook via the following

Sub Button5_Click()
FileToOpen = Application. GetOpenFilename("XML files (*.xml), *.xml")
If FileToOpen <> False Then
ActiveWorkbook.XmlMaps("RouteDoc_Map").Import (FileToOpen)
End If
End Sub

All my XML data comes in great to the associated mapped cells (on several worksheets) but the data that is coming in as a list erases the alternating white/gray conditional formating that I've applied via FORMULA IS =MOD(ROW(),2). How would I be able to preserve the alternating white/gray conditional formating, no matter how many rows are being imported via my button ?

View 6 Replies View Related

Preserve Formatting On Pivot Chart Refresh

Sep 22, 2009

have come across the apparent inflexibility of a pivot chart retaining its user defined formatting whenever it is refreshed.

I understand I can save my chosen formatting as a 'user defined' custom chart, which can be applied post-refresh, but was wondering if a simple bit of code would do this automatically, saving the additional clicks!

how to deal with the attached. How could I adapt the code to call in other 'user defined' charts I may create in the future?

View 8 Replies View Related

Preserve Cells Word Formatting Concatenating Text

Jun 7, 2008

I have a cell with some text in it that has formatting applied (bold in this case). I want to append some text on the end using VBA, but preserve the existing font formatting information. So say I have "one bold one" in my cell, I'm executing the following: ActiveCell.Value = ActiveCell.Value & "two"

But this wipes out the bold information. Is there any way of preserving the bold that's already in the cell. Either perhaps by copying the Characters object and reapplying it, or by some other method?

View 4 Replies View Related

Preserving Pivot Table Formats. Preserve Formatting Checked But...

Aug 28, 2009

I'm having a devil of a time trying to preserve the formatting on a pivot table that I made in Excel 2003. As near as I can tell, I've done the appropriate things --- check the preserve formatting box, uncheck autoformat --- but my formatting is not preserved when I pivot.

Adding to the mystery is the fact that some formatting is preserved but not all. I'm guessing either I'm missing something obvious or this is just an unruly, rogue pivot table that refuses to be formatted.

View 2 Replies View Related

Pasting Data From One Sheet To Another With Formatting And Cell References

Feb 11, 2010

I have inherited a monstrous speadsheet on which all data appears on a single sheet rather than being broken up across several sheets in some logical fashion.

One portion of this monster is a set of quite a few form letters, each of which reference various cells elsewhere in the spreadsheet.

I want to move all of these letters, together, to another tabbed sheet as a first step in reorganizing the monster.

Simply copying and pasting the cells or columns doesn't work. It fails in different ways depending on which pasting options I employ.

A very simplified version of my problem appears on the 5 sheets of the attached file, with what I hope is just enough further detail about the difficulty.

By the way, I also tried using the "Insert Copied Cells" option when pasting but since this failed with the exact same results as one of the other options I didn't include the results in the example shreadsheet.

View 5 Replies View Related

Pasting Cell Values Matching Destination Formatting?

Mar 31, 2014

I have browsed for two days looking for material on effecting this. The technique quoted most is watch for undolist for paste & auto fill then undo the change and paste the value again with specific formatting needs. This technique can be implemented in a worksheet_change event handler. The problem that I am facing is that the user can copy and past while my VBA is running. Once it is caught inside my own application class object event handler all that undo stack is already cleared. Therefore I have nothing that tells me if the user has entered the value via a paste action. By the time the value is pasted, all that formatting would have been entered. For example, a value that is interpreted by another workbook as DATE will have my destination formatting changed to DATE as well even though it is designed to be TEXT at design time.

So far I have not been able to think of a scheme to deal with this.

My basic intention is to always ensure the destination cell formatting remains as TEXT. If something is already interpreted as DATE after the paste even if I can convert to TEXT the string will appear totally differently. I have to find a way to paste the whole thing as TEXT in order to keep the string the same. The problem is that there is no intrinsic PASTE event in VBA. Without a method to undo that paste I cannot catch this at all.

View 1 Replies View Related

Copying And Pasting Conditional Formatting With Changing Cell Values

Mar 19, 2013

How to copy and paste conditional formatting with our changing the cell values. My first row of data starts in row 4 and here is what I have in D4

If D4 is less than or equal to AA4, AW4, BS4, CO4 then it will highlight D4

Now I want to copy that format and paste it for all rows in column D. The problem I'm having though is when I paste the formula it doesn't change to match the row I'm on. For example, when I paste it in D5 this is what I get

If D5 is less than or equal to AA4, AW4, BS4, CO4 then it will highlight D5

How do I paste it so that it will update to show AA5, AW5, BS5, and CO5. I want to be able to do this for 500 rows.

View 6 Replies View Related

BeforeDoubleClick But Preserve Original Cell

Sep 18, 2008

Within Worksheet_BeforeDoubleClick, I have the following simple code extract that sets the appropriate autofilter to the correct value (and highlights a couple of cells for clarity) when a particular cell is double-clicked...

If Not Intersect(Target, Range("C10:AQ11")) Is Nothing Then

If Not Intersect(Target, Range("C10:D11")) Is Nothing Then

Selection.AutoFilter Field:=10, Criteria1:="C"
Range("C10:D11").Interior.ColorIndex = 36

End If

You'll be happy to hear that the event works as expected.

However I would like to add the following enhancement: after Worksheet_BeforeDoubleClick completes the "double-clicked cell" is selected, is it possible for the "original" cell to be re-selected once the event completes?

View 9 Replies View Related

Copy And Pasting Without The Formatting.

Nov 18, 2008

I regularly copy into notepad then copy that into excel because I don't want to carry over the text formatting. Is there a better way to do this? To set up the cells so that they don't try to carry the formatting over?

View 4 Replies View Related

Search & Replace - Preserve Cell Format

Jul 13, 2006

I'm using the code below to do a simple search & replace. The code is working fine.
My problem is after the search & replace is done, certain cells that contain numbers look weird with decimal points & plus signs similar to Format Cells - Scientific. How do I prevent these cells from looking 'weird' in my code?

I've attached a workbook with 2 sheets called Before & After. You can see the 'weird' cells in After.

Sub Macro1()
Cells.Replace What:=": ", Replacement:="", LookAt:=xlPart, SearchOrder _
:=xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False
End Sub

View 5 Replies View Related

Preserve Cell Number Format In Message Box

May 28, 2007

I'm writting an Excell VB application which reads data from my spreadsheet and places it into the text member of an IXMLDOMElement node in order to generate a QBXML request.

The cell I am reading from has datatype number with two decimal places as required by the xml scheme. The problem is that the Range.Value Variant data type drops the decimal point and any trailing zeros so that 1197.00 become 1197. Unfortunately, the QBXML parser requires to see the decimal as well as trailing zeros. So, 1197.90 must show up as precisely that. Changing 1197.90 into 1197.9, for example, also breaks the xml.

My Excel VBA book specifically states that a Variant data type holding numerical data will maintain the data type assigned to it.

I also tried declaring a local decimal (Dim MyDecimal As Decimal) thinking to try copying the Range.Value value to it before assigning to the QBXML field in order to force the correct data format but my VBA macro compiler does not apparently recognize "Decimal" as a valid data type event though my book clearly indicates it is one of the valid VB data types.

I am using Excel 2000. Are these problems solved in newer versions?

View 9 Replies View Related

Pasting Text Without Retaining The Formatting

Nov 20, 2009

I am in a situation where I have to copy-n-paste text from a webpage into Excel. When I do this, the pasted text keeps the formatting of the webpage. The font is the webpage font. The background color is the background color of the webpage. Etc.

I know that I can paste just the text itself, without any of the formatting, by right-clicking, selecting "Paste Special...", and then selecting "Text" instead of "HTML". I am wondering if there is an option somewhere that will do this automatically when I hit CTRL-V instead of requiring me to pull up the Paste Special dialog box.

View 9 Replies View Related

How To Copy Page Formatting When Pasting Into New Workbook

Dec 28, 2011

I've been trying to code a macro that will select a worksheet (that has formulas) to copy just the values into a new workbook. I want the page setup data to also be included. It seems that if a select the workbook and do a copy, it includes the formulas. If I select the cells, then do a paste/special values into the new workbook, the page setup is the default one. Each worksheet that I want to copy/paste has different page setup values and I'd like to be able to carry over the page setup. Otherwise, I have to have code to do all the page setup in the macro. There are over 20 worksheets and it's slow.

This code does the copy/paste special but no worksheet page setup is included

Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ActiveWorkbook.SaveAs Filename:= _
"U:My DocumentsLearning VBA filesTestNewWorkbook.xls"
Windows("ProjectFilesChapter07 test.xls").Activate

View 3 Replies View Related

Array Won't Preserve Values?

Apr 8, 2014

I am trying to store values into a dynamic array. The size of the array will vary each time, so I need the range to be dynamic. Most importantly, I need all values to be retained in the array. Currently, a value will be stored, but once the next round of the for loop is initiated, the array changes to "<subscript out of range>" and stays that way until the it is replaced by the next value. So, there isn't an accumualtion in the array--it goes one value, to out of range, to one value, etc.

View 8 Replies View Related

VBA - Preserve Hyperlink When Using VLOOKUP?

May 26, 2014

I am having when trying to preserve a hyperlink when using VLOOKUP. I have two worksheets within the same workbook. Worksheet 1 contains a lot of information for internal use(many of the cells in all of the columns contain hyperlinks to web addresses), and Worksheet 2 should be a version identical to this, showing only the selected columns suitable for external use. This is to avoid using two different 'work trackers'; so, when info in Worksheet 1 is updated, Worksheet 2 should automatically be updated and reflect this.

I am currently using the following code:

Function GetHyperLink(r As Range) As String
If r.Hyperlinks.Count Then
GetHyperLink = r.Hyperlinks(1).Address
End If


View 8 Replies View Related

Convert To Pdf Preserve Link

Aug 27, 2009

I m trying to save my excel file as a pdf. all is working great except the fact that i have a few cells that contain hyperlinks (via HYPERLINK formula). when exported, they are being converted to a simple text, loosing the link.

thus my question is this, would anyone know of a proper way to export an excel file so that ALL hyperlinks are preserved? be it with excel or any other program/converter.

View 9 Replies View Related

Preserve Function When Inserting Cells

Apr 21, 2009

I'm using IF functions to get the difference of two cells. An example:

View 5 Replies View Related

Delete Rows But Preserve Formula?

Apr 29, 2012

I have an inventory sheet with rows containing a formula. I've placed the same formula in all 65536 rows that Excel 2003 has.

I have a macro to delete unused items. It searches for an item number then deletes that row. (Actually it deletes the item number and a partial row based on an offset, but that was for an earlier version and an entire row would be okay) When a row is deleted, all the other rows move up and Excel creates a new last row (65536) The problem is that this new row has no formulas. While it's probably unlikely that I'll ever blow through 65536 rows, it seems sloppy to leave this unaccounted for.

Is there a way to either add the existing formula(s) to the last row...or insert a new row *somewhere* that is empty except for the formula of the other rows in the sheet? Here's what I have for the existing code.

'Search for item to delete based on entry to InputBox
Sub Delete_Item()
Dim FindString As String
Dim Rng As Range
Dim YesOrNoAnswerToMessageBox As String
Dim QuestionToMessageBox As String


View 9 Replies View Related

VB Code To Reinstate/preserve Formula

Apr 25, 2009

My current headache is that I want to be able to reinstate excel formula when the delete key is hit. However there this is a slight catch. I don't just want to be able to do this for one cell but reinstate the same excel forumla in an entire cloumn (ie for multiple rows). On top of this I also need to find a way of being able to do this for multiple columns (ie column 1 has formula 1, column 2 has formula 2 etc.....)

I have found this but I am having trouble adapting it to suit my purpose. This code just reinstates the formula for 1 cell.

Worksheet module:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address "$A$1" Then
Application.OnKey "{del}"
Application.OnKey "{del}", "myFormula"
End If
End Sub

Sub myFormula()
Worksheets("Sheet1").Range("A1").Formula = "=RC[1]+RC[2]"
End Sub

View 9 Replies View Related

Preserve Formula References After Sort

Oct 23, 2006

I have noticed that if I create a row and put a reference formula in one of the cells (i.e. in Cell B3 I have "=B4", to show contents of B4), then after I do Sort and Row 3 moves else where, formula in what used to be B3 no longer points to B4, but rather to B<new row + 1>.

Absolute reference doesn't seem to be an option (i.e. "=$B$4") since after sorting rows in question the cell references in my B cells do get screwed up. I guess I want to bind a certain cell to a certain other cell, and keep that bind no matter where I move the row.

View 9 Replies View Related

Modify Array Forumula And Preserve Brackets

Dec 11, 2008

How would I modify a (very long) array formula, while preserving the brackets? Or re-creating them? I've tried doing it "at the cell" without luck.

View 2 Replies View Related

Macro Is Copying And Pasting Into Cell A2 On New Sheet Instead Of Cell A1

Jun 20, 2014

I have a macro that copies all my sheets onto a new sheet called combine. It is pasting onto the combine sheet starting on cell A2 instead of cell A1. Following is my macro.

Sub Combine()
Dim J As Integer
Sheets(1).Name = "Combined"
On Error Resume Next
For J = 2 To Sheets.Count
Selection.Copy Destination:=Sheets("Combined").Cells(Rows.Count, 1).End(xlUp)(2)
End Sub

View 4 Replies View Related

Lock Format In Cell - Even If Copy And Pasting To That Cell

Aug 17, 2006

Is it possible to lock in the formatting that would require 12 digits even if someone was copying and pasting to the cell?

We are looking to make our users add information into cells in the format 0-00000-00000-0. They are often copy and pasting, thus overwritting the custom format we have in those cells.

I've looked at validation, but custom only works for a formula.

View 9 Replies View Related

Pasting Only Numbers From A Cell

Aug 12, 2014

I have cells that include phone numbers emails and names and I just want to copy and paste the phone number, how do I do that ;?

View 3 Replies View Related

Numbers Not Pasting Right In The Cell?

Nov 25, 2013

I'm trying to paste the number 1-987654321 into cell A1. But when I click the cell onces then Ctrl+V to paste, it converts the number. It puts 1 into cell A1 and 987654321 into cell A2. I've tried changing the format of the cell to TEXT and GENERAL but that doesn't work. Now I can double click the cell and then paste and that works. My only issue with that is all the other data I'm pasting into the spreadsheet, I'm able to do so by only clicking once. This spreadsheet will be used by 20 people and I'm afraid that if they paste by click once in all the other cells and have to double click to paste in this cell, that it will cause confusion and a headache for me.

View 4 Replies View Related

Pasting Into A Single Cell

Apr 10, 2013

I'm working with the sort of data that spills over into multiple cells if you try to paste it without first putting the cursor in the function window. Is there any way to change this default behaviour (or, alternately, automatically redirect the cursor to the function window every time I hit "enter" and go to the next cell)? I'm working with literally thousands of entries, so the time spent double-clicking and/or manually redirecting the cursor to the function window adds up after a while.

View 1 Replies View Related

Copyrights 2005-15, All rights reserved