Link to home
Start Free TrialLog in
Avatar of speechrec
speechrecFlag for Switzerland

asked on

Formatting an Excel document after creation with VBA

Hi

I am using Excel for creating offers and bills.
I'm really fast at it, too. But one thing is kind of tedious.

I have a formatting requirement:
Between each row that has text, there should be one row, and only one, that is empty.
The height of the row should be 15.

Unfortunately, I do not know how to keep the number of empty rows constant.
What's more, the empty rows should have the same height.

So, after creating the document, I would like to run a macro that makes sure that
1) omitted rows are inserted,
2) single empty rows with the wrong height adjusted, and
3) double or triple rows that are empty deleted.

So here's what I desire:

Here's sth bold
Here's an empty row. Height: 15
Here's some text
Here's an empty row. Height: 15
Here's some more text
Here's an empty row. Height: 15

What I may have is something like this:
Here's sth bold
Here's an empty row. Height: 30
Here's an empty row. Height: 15
Here's some text
Here's some more text
Here's an empty row. Height: 40

Is it possible to create a macro for this?
I know only some VBA and mostly from code that I got with the macro recorder and adapted.

Thanks!
Screenshot---18.04.2011---18-24-.png
Avatar of SiddharthRout
SiddharthRout
Flag of India image

>>s it possible to create a macro for this?
I know only some VBA and mostly from code that I got with the macro recorder and adapted.

Yes :)

If you can upload the file I will directly write a macro for that. That way, I'll get my references correct as well in one go :)

Sid
ASKER CERTIFIED SOLUTION
Avatar of Saqib Husain
Saqib Husain
Flag of Pakistan image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of speechrec

ASKER

ssagibh
This is quite good.
Is there any way to stop it after line 200?
I never go further than that at it doesn't need to loop all the way through.
Change

If rw.Row > 1 And rw.Row < ActiveSheet.UsedRange.Rows.Count Then

to

If rw.Row > 1 And rw.Row < 200 Then
Thanks, that was it!