Results 1 to 5 of 5

Programmatically Enter IF Statement Using Variables

Threaded View

ajocius Programmatically Enter IF... 12-18-2012, 01:51 PM
Norie Re: Programmatically Enter IF... 12-18-2012, 02:00 PM
ajocius Re: Programmatically Enter IF... 12-18-2012, 05:24 PM
Norie Tony The only thing that... 12-18-2012, 05:36 PM
ajocius Re: Programmatically Enter IF... 12-23-2012, 05:31 PM
  1. #1
    Forum Contributor
    Join Date
    12-22-2004
    Location
    Kokomo, Indiana
    Posts
    236

    Question Programmatically Enter IF Statement Using Variables

    I have Windows XP and running Excel 2010. Can someone of the collective show me how to programmatically write the following IF statement in VBA? On the internet and in this forum seen examples which use the amersand. No matter what I do I continue to get errors.

    Dim LastRowInDatabase as Variant
    Dim FirstRowInDatabase as Variant
    '
    LastRowInDatabase = 1294
    FirstRowInDatabase = 2
    '
    For FirstRowInDatabase = FirstRowInDatabase  To LastRowInDatabase  Step 1
    ' 
       ActiveSheet.Cells(FirstRowInDatabase, 52).Select
        'ActiveCell.FormulaR1C1 = "=IF(D2="","",COUNTIF($D$2:D2,D2))"
        ActiveCell.FormulaR1C1 = "=IF(D2="","",COUNTIF($D$2:D2,D2))"
    '
    Next FirstRowInDatabase
    Change From:
    ActiveCell.FormulaR1C1 = "=IF(D2="","",COUNTIF($D$2:D2,D2))"
    Change To:
    ActiveCell.FormulaR1C1 = "=IF(D & "FirstRowInDatabase " = "","",COUNTIF($D$2:D & "FirstRowInDatabase",D & "FirstRowInDatabase"))"
    Last edited by ajocius; 12-23-2012 at 05:32 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1