Consulting

Results 1 to 6 of 6

Thread: Excel program & left in the lurch--please help

  1. #1
    VBAX Newbie
    Joined
    Nov 2016
    Posts
    4
    Location

    Excel program & left in the lurch--please help

    Hi,

    I have a program that was developed for me but the programmer is no longer available. In the following routine below (line 2) I'd like to be able to have the "S" value multiplied by 12 (S*12) but every way I try to get it to work, i.e. to add double quotations, parenthesis, etc around the S value, I always get an error when executing the macro.

    Can someone please tell me how to get this to work?

    Much thanks,

    Quadvark

    For r = md2.startRow To md2.endRow - 1
    Range("A" & r) = "=(C" & r & " + E" & r & " + Q" & r & " + S" & r & ")/4"
    Range("A" & r).NumberFormat = "0.0"
    Next
    Last edited by Quadvark; 11-13-2016 at 10:56 PM.

  2. #2
    VBAX Expert
    Joined
    Sep 2016
    Posts
    788
    Location
    Range("A" & r) = "=(C" & r & "+E" & r & "+Q" & r & "+12*S" & r & ")/4"

  3. #3
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,877
    Without looping:
    With Range("A" & md2.startRow & ":A" & md2.endRow - 1)
      .FormulaR1C1 = "=(RC[2]+RC[4]+RC[16]+12*RC[18])/4"
      .NumberFormat = "0.0"
    End With
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

  4. #4
    VBAX Newbie
    Joined
    Nov 2016
    Posts
    4
    Location

    Thanks!!

    Quote Originally Posted by p45cal View Post
    With Range("A" & md2.startRow & ":A" & md2.endRow - 1)
      .FormulaR1C1 = "=(RC[2]+RC[4]+RC[16]+12*RC[18])/4"
      .NumberFormat = "0.0"
    End With
    Looks like I came to the right place to get this answered. I really appreciate the help from both, mana & p45cal, so thanks so much!

  5. #5
    VBAX Newbie
    Joined
    Nov 2016
    Posts
    4
    Location
    Thank you mana.

  6. #6
    VBAX Newbie
    Joined
    Nov 2016
    Posts
    4
    Location

    Newbie and it shows

    I'll quit why I am ahead with all the thank you posts as it really shows I haven't worked in a forum much with my repeated replies saying as much.

    I'll do better in the future as I am sure I will be back. And as I've said before...thanks for your help.

Posting Permissions

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