Solved

with excel vba how can I transfer the text in one cell to another with losing all the formatting

Posted on 2013-06-25
4
418 Views
Last Modified: 2013-06-26
I have highly formatted cells which I want to transfer to other cells progrommaticly with vba
how do I do this without losing formatting?
0
Comment
Question by:Dov_B
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 47

Accepted Solution

by:
Martin Liss earned 100 total points
ID: 39274792
To copy both values and formatting do something like this.

    Selection.Copy
    Range("A3").PasteSpecial Paste:=xlPasteAllUsingSourceTheme, Operation:=xlNone _
        , SkipBlanks:=False, Transpose:=False
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
0
 
LVL 20

Assisted Solution

by:dsacker
dsacker earned 200 total points
ID: 39274793
This is an example. You can change out the "Range" for "Cells", if you are looping through columns or rows, and use the same methods.
Public Sub TestThis()
    ' Have a specially formatted value in D5, and move it to F5
    Range("D5").Select
    Selection.Copy
    Range("F5").Select
    ActiveSheet.Paste
    Application.CutCopyMode = False

    ' If you need to clear the formatting in your source, do this.
    Range("D5").Clear
End Sub

Open in new window

0
 
LVL 13

Assisted Solution

by:Shanan212
Shanan212 earned 200 total points
ID: 39274796
    Range("H14").Select
    Selection.Copy
    Range("J14").Select
    ActiveSheet.Paste
application.cutcopymode=false

Open in new window


Considering you want to copy from H14 to J14
0
 
LVL 47

Assisted Solution

by:Martin Liss
Martin Liss earned 100 total points
ID: 39274798
And in my example if you just want to copy the formatting do just the first of the two PasteSpecials.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

697 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question