+ Reply to Thread
Results 1 to 9 of 9

If cell = G2 then place 1 macro help???

  1. #1
    Registered User
    Join Date
    04-29-2016
    Location
    USA
    MS-Off Ver
    2013
    Posts
    92

    If cell = G2 then place 1 macro help???

    I am new to Macros. I have a Spreadsheet and it will vary how many rows it has but I want it to Input a 1 in G Column if F Column = "G2". I know I can use a formula but I already have a bunch of macros in this workbook and would just like to add a new macro.

    Also Can I do a Macro where if it Equals something multiply Column C by -1? But it's tricky because I need it to do it if:
    F Column equals "G" and J Column <= 35
    F Column equals "G2"
    If F Column = "G3" and J Column <=6

    I've been working on all the other things for hours these are my last two steps. Please help!

  2. #2
    Registered User
    Join Date
    06-04-2019
    Location
    U.S.
    MS-Off Ver
    2016
    Posts
    48

    Re: If cell = G2 then place 1 macro help???

    Alesha,

    Good morning!! Just had a quick question for you. Are you saying that if a cell in F column, let's say F1, has the value G2, then you want to put the number 1 into the cell G1?? Or are you saying that if a cell, say F1, has the same value as the cell G2, then you want to put the number one into a particular cell in the G column?? This same question also pertains to the rest of your macro needs. Please elaborate and specify a little more that way we can give you the best help possible. Thank you!!

    Dome

  3. #3
    Registered User
    Join Date
    04-29-2016
    Location
    USA
    MS-Off Ver
    2013
    Posts
    92

    Re: If cell = G2 then place 1 macro help???

    Ok sorry about that, I am never good at explaining on here.

    If F1=G2 then put 1 in G1. G Column is Blank.

    For the Other if
    F1=G & J1=35 Column C1 amount of 125.00 would change to -125.00
    F2=G & J2=34 Then C2 of 150.00 would remain 150.00

    Hope this helps!
    Hope that helps

  4. #4
    Registered User
    Join Date
    06-04-2019
    Location
    U.S.
    MS-Off Ver
    2016
    Posts
    48

    Re: If cell = G2 then place 1 macro help???

    Ms. Alesha,

    No worries, just need to ensure we are giving you what you are looking for =) Try something along these lines:

    Please Login or Register  to view this content.
    I didn't put in the code for F2=G & J2=34, since this code will only act on the C column given that the value in the J column is 35. Hope this helps, let me know if it needs tweaked a bit.

    Dome
    Last edited by BrokenDome; 06-05-2019 at 03:06 PM. Reason: Change info

  5. #5
    Registered User
    Join Date
    04-29-2016
    Location
    USA
    MS-Off Ver
    2013
    Posts
    92

    Re: If cell = G2 then place 1 macro help???

    I keep getting a Syntax Error?
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    06-04-2019
    Location
    U.S.
    MS-Off Ver
    2016
    Posts
    48

    Re: If cell = G2 then place 1 macro help???

    Ms. Alesha,

    Yes ma'am, my fault. I put an End For instead of a Next x. I have edited my code in my last post and I believe it should work for you now.

    Dome

  7. #7
    Registered User
    Join Date
    04-29-2016
    Location
    USA
    MS-Off Ver
    2013
    Posts
    92

    Re: If cell = G2 then place 1 macro help???

    Everything worked GREAT Except:

    When F=G2 I need it to multply by -1 also so Here is the one I edited. What did I do wrong?

    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    06-04-2019
    Location
    U.S.
    MS-Off Ver
    2016
    Posts
    48

    Re: If cell = G2 then place 1 macro help???

    Ms. Alesha,

    It would never go to the ElseIf Range("F" & x).Value = "G2" because it would stop on the original If statement where we already checked for the value in the F column. You need to combine both checks into one like the following:

    Please Login or Register  to view this content.
    You just can't have an if statement checking something, followed by and elseif statement that checks for the same thing, because the statement would end at the first check, and never continue to the second. Hope that makes sense.

    Dome

  9. #9
    Registered User
    Join Date
    04-29-2016
    Location
    USA
    MS-Off Ver
    2013
    Posts
    92

    Re: If cell = G2 then place 1 macro help???

    Works Great! Thank you so much for all of your help!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 1
    Last Post: 05-24-2018, 11:24 AM
  2. [SOLVED] Macro to place last date of the month in cell
    By robrobet in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-18-2013, 02:48 PM
  3. Using Macro to place formula with a variable into a cell
    By Melissa9 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-20-2013, 01:40 PM
  4. [SOLVED] Need a Macro to pull data from one cell and place into another one time
    By jgregory43 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 08-05-2013, 03:26 PM
  5. Macro Help that will place value in Cell if row is highlighted
    By C53105 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-14-2013, 04:48 PM
  6. Help creating a Combo Macro to place data into another cell
    By Darth269 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-05-2012, 08:15 AM
  7. Replies: 6
    Last Post: 09-30-2009, 04:25 PM

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