• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

How to get a produce a report sheet with VBA

Espresso

New Member
Hi all,

I'm a bit of a noob and just starting to move to macro's and VBA.
Fiddling with sheets...that I get...fiddling with VBA is a whole other world.
Filling a database with a form is working greet.
Creating a report sheet with Excel also not a problem..
But now I want that report sheet generated with VBA....and now I'm lost.

The following question:
  • source sheet= "Database' (thats getting filled, modified all the time)
  • overview/report sheet = 'Report"

I want the sheet Report filled with data from sheet Database.

Basically I need every row in the report sheet. So I just let it copy everything from
Column A en B which contain the unique identifier en name and I capped it to 2000 rows.

I need the data in a simple graphical output (3 Icons green, yellow and red)
So I'm using the following:

If there is no value in column C; Result = 0
If there is a any value in column C and no value in column AC; Result = 1
If there is a any value in column C and a value in column AC; Result = 2

(Then repeat this for D with AD; E with AE; etc... to Z with AZ)

On the report sheet I use conditional formatting as the result is 0;1 or 2

I currently use a simple formula. But it's a heck of a work to fill all the fields.
And not a 'clean solution' using simple Excel If-Then-Else.

Sample Formula used:
Report!$A$2 =Database!$A$2

Report!$B$2 =Database!$B$2

Report!$C$2 =IF(Database!$C$2<>"";(IF(Database!$AC$2<>"";2;1));0)

Report!$D$2 =IF(Database!$D$2<>"";(IF(Database!$AD$2<>"";2;1));0)

. . .

Just not sure how to get this done in VBA and autogenerate the sheet.
If someone can give me a starter/tip how to approach this I'd be very thankful.

Thanks for taking time and your responses!

Edit:
From this thread and the link to rondebruin.nl I'm learning how to create sheets. But how to get the conditional (0,1,2) simplified results in VBA is kinda tough
 
Last edited:
Well one step further.
Got it working on a single cell...
Now need to figure out how to fill a whole sheet...:confused:

Code:
Sub Test()
' Test Macro
' ActiveCell.Formule starting postion in source sheet
' R = Row - C = Column
    Range("C2").Select
    ActiveCell.FormulaR1C1 = _
        "=IF(Database!R2C29=TRUE,(IF(Database!R2C29<>"""",2,1)),""0)"
    Range("C3").Select
End Sub
 
Back
Top