Results 1 to 6 of 6

Thread: easy vba question

  1. #1

    Thread Starter
    Fanatic Member Crash893's Avatar
    Join Date
    Dec 2005
    Posts
    930

    easy vba question

    My boss wants to do this in her code

    If CurrentTitle = "DOM" Or "USA" And HeaderNum = "2" Then

    If prev = "EAST" And vari = "FOLIO" Then

    MakeChanges2_9

    Application.StatusBar = "2_9Using EAST Zone FIRST Edition as source for FOLIO Zone"

    End If

    End If

    but its getting a syntax error on the or

    I think it should be


    If CurrentTitle = "DOM" Or CurrentTitle = "USA" And HeaderNum = "2" Then

    but i don't have anything to compile vba so if some one knows for sure then please let me know

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: easy vba question

    you do not need to compile vba to exe, it jut runs in the code windows on excel, word or other office application

    but your solution looks correct
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  3. #3
    Head Hunted anhn's Avatar
    Join Date
    Aug 2007
    Location
    Australia
    Posts
    3,669

    Re: easy vba question

    Make it clearer, you should write:
    Code:
    If (CurrentTitle = "DOM" Or CurrentTitle = "USA") And (HeaderNum = "2") Then
    From VBA (in Access, Excel or Word, ...) you cannot create EXE but you can compile the code from menu [Debug]>[Compile VBA Project].
    • Don't forget to use [CODE]your code here[/CODE] when posting code
    • If your question was answered please use Thread Tools to mark your thread [RESOLVED]
    • Don't forget to RATE helpful posts

    • Baby Steps a guided tour
    • IsDigits() and IsNumber() functions • Wichmann-Hill Random() function • >> and << functions for VB • CopyFileByChunk

  4. #4
    Frenzied Member
    Join Date
    Aug 2006
    Location
    India, Punjab, Bhatinda
    Posts
    1,689

    Re: easy vba question

    as your poser relates to VBA PM mods to move the post to office dev page so that you might get more responses (if you have not already got your solution)

  5. #5
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: easy vba question

    Moved To Office Development

  6. #6
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: easy vba question

    Like Anhn suggested, your code should be clearer to read. you can further clean it up and write it as...

    vb Code:
    1. Sub test()
    2.  
    3. If (CurrentTitle = "DOM" Or CurrentTitle = "USA") And (HeaderNum = "2") _
    4. And (prev = "EAST") And (vari = "FOLIO") Then
    5.  
    6.     'use "Call", if it is a sub
    7.     Call MakeChanges2_9
    8.  
    9.     Application.StatusBar = "2_9Using EAST Zone FIRST Edition as source for FOLIO Zone"
    10.  
    11. End If
    12.  
    13. End Sub

    Hope this helps...
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

Posting Permissions

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



Click Here to Expand Forum to Full Width