Keep Original Sheets Font Format when Populating data into other sheet


C

Corey ....

Is use this sort of code to pupulate data from one sheet to the other:

With ActiveWorkbook.Worksheets("Sheet A")
..Select
Dim rngFound As Range
On Error Resume Next
' Gain the Location of the Combobox.Value
With Worksheets("Sheet B").Range("A:A")
Set rngFound = .Find(What:=Me.TextBox4.Value, After:=.Range("A1"),
LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows,
SearchDirection:=xlNext, MatchCase:=False, Matchbyte:=False)
' Place Data
Range("O4").Value = TextBox4.Value
Range("O2").Value = rngFound.Offset(-1, 4).Value
Range("E2").Value = rngFound.Offset(-1, 2).Value
Range("E4").Value = rngFound.Offset(0, 2).Value



I want the Font Format to be AS IS from sheet1 to sheet2.

Some of the Fonts haver Font.Strikethrough, but when the data is copied to
the other sheet using the above code, the fonts are always normal.

How can i adapt the code to do this?
Is it possible to do this by a line of code, rather than changing each
(rngFound.offset(*,*)) line ?


Corey....
 
Ad

Advertisements

J

Jim Thomlinson

All you are doing is making one value equal to the other. you are not doing
anything to change the formats. To do that the easiest is to copy and paste
(or pastespecial if your found cells are formulas.). There is no easy one
liner as you would like...
 
C

Corey ....

Jim,
thanks for ther reply.

So something like this:
rngFound.Offset(-1, 4).Copy
Range("O2").Paste

And do likewise to ALL cells?
 
Ad

Advertisements

C

Corey ....

Solved. Used:
*************************
Range("C12").Value = rngFound.Offset(2, 2).Value
If rngFound.Offset(2, 2).Font.Strikethrough = True Then
Range("C12").Font.Strikethrough = True Else Range("C12").Font.Strikethrough
= False
' and so on.........................
************************
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top