+ Reply to Thread
Results 1 to 5 of 5

'If' syntax

Hybrid View

hvisa 'If' syntax 01-30-2007, 12:26 PM
EdMac Hi ... 01-30-2007, 01:00 PM
VBA Noob Hi, Just to add if... 01-30-2007, 02:00 PM
hvisa I think I explained it wrong.... 01-30-2007, 04:13 PM
VBA Noob Hi, You can use an event... 01-30-2007, 04:33 PM
  1. #1
    Registered User
    Join Date
    07-28-2005
    Posts
    73

    'If' syntax

    Is it possible to use IF( a2=5) then select a range of cells.
    if yes, what is the syntax.

    Thanks

  2. #2
    Forum Contributor EdMac's Avatar
    Join Date
    01-23-2006
    Location
    Exeter, UK
    MS-Off Ver
    2003
    Posts
    1,264
    Hi

    =if(a2=5,do_this,else_do_that)

    HTH

    Ed

  3. #3
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Hi,

    Just to add if condtion return text add quote marks. Numbers don't require quote marks

    E.g

    =if(a2=5,"do_this","else_do_that")

    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  4. #4
    Registered User
    Join Date
    07-28-2005
    Posts
    73
    I think I explained it wrong. Sorry.
    Is it possible to use in a IF statement , if the condition is true, then copy range of cells.
    Is it possible to do copy a range of cells say D2:D5 if the condition is true.

    Thanks

  5. #5
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Hi,

    You can use an event macro.

    Right click sheet name and select view code. Paste below into sheet.

    This will copy your range if A1 = true.

    Private Sub Worksheet_Change(ByVal Target As Range)
    
    If Range("A1").Value = True Then
    Range("D2:D5").Copy
    End If
    
    End Sub
    Replace the bold line above if you want to copy it to a new area e.g E2

    Range("D2:D5").Copy Range("E2")

    VBA Noob

+ Reply to Thread

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