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
371 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
  • 2
4 Comments
 
LVL 45

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 45

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

A2 = A1 That kind of cell reference is relative.  If you copy it from A2 to B2, then B2 will get this: B2 = B1 That's all fine and good, but if you then insert a new row above row 2, you'll find: A3 = A1 B3 = B1 This is intentional. …
How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.

707 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now