retrieve .values and their formatting from source

XL_NOOB_89

New Member
Joined
Feb 8, 2022
Messages
4
Office Version
  1. 365
Platform
  1. Windows
I see a ton of posts on this topic, but none of them are actually what I'm struggling with. The code below works fine, but it only carries over the values of the source cell (.values). I'm looking to also carry over the source formatting from the Input sheet - the source formatting will be dynamic. I don't want to use the .copy/.pastespecial command. Majority of the source cells on the Input sheet are text, but can also be numbers at times.

I'm basically running through a massive list on the Input sheet and copying everything over to the Output sheet with a row in between each line. I've tried multiple variations in the With clause, but nothing seems to work. Any help would be appreciated:

VBA Code:
Sub DataRetrieval()

Dim LR As Long, i As Long
Dim wsInput As Worksheet
Dim wsOutput As Worksheet
Dim lCount As Long
Dim CommRow As Long
Dim TheMark As Range

Set wsInput = ThisWorkbook.Worksheets("Input")
Set wsOutput = ThisWorkbook.Worksheets("Email Output")
Set TheMark = wsInput.Range("C3")

wsOutput.Range("C9:C1000").ClearContents
wsOutput.Range("C9:C1000").ClearFormats

CommRow = 9

For lCount = 1 To WorksheetFunction.CountIf(wsInput.Columns(3), "*")

Set TheMark = wsInput.Columns(3).Find(what:="*", after:=TheMark, LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False)
   
With TheMark
        wsOutput.Range("C" & CommRow).Value = TheMark
End With

    CommRow = CommRow + 2
   
Next lCount

End Sub
 
Last edited by a moderator:

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
If you don't want to copy and paste, I think you have to set each piece of the format separately.
VBA Code:
wsOutput.Range("C" & CommRow).Font.size = TheMark.Font.size
wsOutput.Range("C" & CommRow).Font.bold= TheMark.Font.bold
wsOutput.Range("C" & CommRow).interior.color = TheMark.interior.color
etc. - I just put a couple of options in there.

I'm not aware of an all in one format property that would get them all in one shot, however I could be wrong.
 
Upvote 0
Solution
If you don't want to copy and paste, I think you have to set each piece of the format separately.
VBA Code:
wsOutput.Range("C" & CommRow).Font.size = TheMark.Font.size
wsOutput.Range("C" & CommRow).Font.bold= TheMark.Font.bold
wsOutput.Range("C" & CommRow).interior.color = TheMark.interior.color
etc. - I just put a couple of options in there.

I'm not aware of an all in one format property that would get them all in one shot, however I could be wrong.
This seems to be what I need. Thank you!
 
Upvote 0

Forum statistics

Threads
1,215,065
Messages
6,122,944
Members
449,095
Latest member
nmaske

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top