Results 1 to 4 of 4

need help with VBA syntax

Threaded View

  1. #1
    Registered User
    Join Date
    07-05-2011
    Location
    ohio
    MS-Off Ver
    Home and Business 2010
    Posts
    5

    need help with VBA syntax

    I'm new to VBA and writing macros, and I'm not familiar with the proper syntax for generating my own code. I would really appreciate some help with this, it would make life a lot easier if I could write a macro to do what I'm currently doing with formulas.

    Lets say I'm using the following formula, which I have pasted all down column D. Based on whatever row we've pasted this into, were going to see whats in column B, then check whats in column C, then check to see if I2 contains anything (this is a box I use to switch between metric and standard), and based on all this criteria, we output something like:

    whateverswritteninB3 (0.000)
    =B3&IF(ISBLANK($C3),"",IF(ISBLANK$I$2)," ("&TEXT($C3,"0.000")&")"," ("TEXT(($C3/25.4),"0.0000")&")"))

    I'd like to do this in VBA, and while I dont know the proper syntax, the way I'm thinking about it in my head is:
    dim InDes as ??, InVal as ??
    
    InDes = target.offset(0,-2) 'this cell could contain text or a formula. I want to copy whatever the cell is actually showing. 
    
    InVal = if target.offset(0,-1) = "" then InVal = "" 
    elseif 
    cell I2 is empty then 
    InVal = value.target.offset(0,-1) 
    force format of 0.000
    elseif 
    cell I2 is not empty then 
    InVal = value.target.offset(0,-1)/25.4
    force fromat of 0.0000
    
    
    If (Not Intersect(Target, Range("D:D")) Is Nothing) Then
                If (Not IsEmpty(Target)) Then
                        if InVal = "" then
                        target = InDes
                        else
                        target = InDes & " (" & InVal & ")"
    Last edited by cbrf23; 07-05-2011 at 02:07 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