Iterate through, Format Cells in VBA

msaluta

New Member
Joined
May 30, 2018
Messages
4
I have an automated report that generates a table of values that need to be iterated through and saved to a different format.
Here is the table:
<code style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; vertical-align: baseline; box-sizing: inherit; white-space: inherit;">John Smith 5/26/2018 12345 IT Pro John Gault Permitting Sarasota
Winston Smith
5/30/2018 54321 Henchman Bob Licensing Oceania</code>The format that I'm looking to get that information to is the following:
<code style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; vertical-align: baseline; box-sizing: inherit; white-space: inherit;">Name: John Smith
Date Starting: 5/26/2018
Employee ID
#: 12345
Title
: IT PRO
Supervisor
: John Gault
Bus Ctr
: Permitting
Location
: Oceania

Name
: Winston Smith
Date Starting: 5/30/2018
Employee ID
#: 54321
Title
: Henchman
Supervisor
: Bob
Bus Ctr
: Licensing
Location
: Oceania</code>The amount of employees on the report will change on a given day, so I believe a For Each is in order, something to the effect of:
<code style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; vertical-align: baseline; box-sizing: inherit; white-space: inherit;">For Each Cell In ActiveSheet.UsedRange.Cells</code>I'm just uncertain what to put into the For loop.

 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
I have a question- I copied your two lines of text

John Smith 5/26/201812345 IT Pro John Gault Permitting Sarasota
Winston Smith
5/30/201854321 Henchman Bob Licensing Oceania

and in parsing it I discovered that there are two non printing characters "chr(160)" in each string of text (which while not too unusual, but not the norm).

So my question is, did you do a cut and paste from your report into this post.
 
Last edited:
Upvote 0
Yes I did. I copied and pasted from a less than helpful Stack Exchange post, which has its own formatting. (Some of which didn't show up until after I posted in this window)
 
Upvote 0
@msaluta
If you have posted this question on other sites please post a link to those sites, as per forum rules.
Please see Rule#13
 
Upvote 0
Okay, so is your generated data dumped as an excel file. If that is the case, where are the strings of text located and where would you like your new format located (sheet & range). Also, if you could copy and paste a string from the dump, it would help to see how it is formatted when you first get it.
 
Upvote 0

Forum statistics

Threads
1,215,327
Messages
6,124,292
Members
449,149
Latest member
mwdbActuary

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