if then else vba code

  1. F

    IF Cell Value Then Else

    2019 Excel On Windows 10 I am trying to write a VB Macro (IF Then Else) that looks at the current active cell Value (a number) = a specified number and then determines which Subroutine to go too. I am stuck on the IF portion. All Help appreciated. Fred7
  2. S

    Combining VBA routines

    I can't seem to figure out how to combine (2) VBA routines. I want both of them to run at the same time. My worksheet contains header rows for "Super Projects" and rows below are "Projects". This repeats through the worksheet: Super Project (random color 1 in "A" through "Y") Project (random...
  3. V

    Need cells to lock until a comment is added in the comment cell then unprotect sheet

    I am new to visual basic and need some help with some coding. I have a excel template that has an plan end date and actual end date (2 separate columns) if my actual end date is greater then my plan end date, I need a message box to explain they need to write a comment. If there is no comment...
  4. S

    A complete beginner's solution to nested If-Then constructs

    Hi all, I'm an absolute beginner in vba (started two weeks ago). In short, can you tell me why the code always skips the part in red font and goes straight from the "Then" statement in blue to the "Else" statement in blue, irrespective of whether the statement If Sheet.Name = UCase(szToday) is...
  5. D

    Worksheet check macro sub-routine

    ;) Greetings! I searching for assistance in writing a VBA macro that will check each cell in a range for the existence of a specific text string "Mismatch". If the text string exists a Msgbox "Mismatch Found!"; if not Msgbox "Worksheet Checks Good!" would appear. Worksheet: CREW30 Range...
  6. P

    vba - internediate step test

    hello. i have a macro that is approximately: ___ do paste values_1 for n = 1 to 6 calculate paste values_2 paste values_3 next n ___ i would like to put a test between "calculate" and "paste values_2", so that: ___ if the value of a certain cell = 0 Then stop going through the "for...
  7. M

    If/Then Logic For VBA Save As functionality?

    Hello, I am working on a project in Excel 2010 that will automatically save a file using a specific naming protocol, based off the dates included on the spreadsheet. Right now, I have the following code working perfectly for today's date Sub Save() Dim dtDate As Date dtDate = Date Dim...
  8. T

    VBA Macro for Cells with Conditional Formatting

    So here is what I am trying to do.... I have a form/timesheet that needs to filed out by employees that are working on projects for customers. The form is often filled out incorrectly or items are omitted that are necessary for our purposes. So I end up having to go back to the employee and...
  9. T

    If, ElseIf, Else Statements with Multiple Conditions

    Hi All! I have been experiencing this issue in a few macros I've created and don't understand what is wrong with any of the syntax structures I've been experimenting with. When I run the code, it doesn't compile and gives me a message that says "Else without If." From online research, it seems...
  10. D

    If / Then VBA statment that moves through range where relative reference of formula changes

    Hey Forum: I have gotten stuck and am hoping for some help (admittly still learniing VBA, so be kind). So far I have written the below code: Sub More_Adjustments() Dim rng As Range Set rng = Sheets("Adjustments").Range("I8:I50") For Each cell In rng If Sheets("Adjustments").Range("I8") =...
  11. R

    IF macro VBA

    Hi, i want to make a macro with a if formula that takes a value and placed it on the right row every row got's a specific date. this is what i got so far: If Sheets("Data").Range("A2") = "1" Then Sheets("Numpay").Range("F312").Copy Sheets("3C").Select Range("D12").Select...
  12. V

    Excel VBA If...Then Function not working

    Hello, I'm new to VBA and the board so I'm sorry if I'm unable to explain myself very well or if I've posted this in the wrong place. I have been trying to create a function with the "if then statement" to calulate the cost of a produce all with differing angles, finish, pipe size and product...
  13. S

    IF else vb after combo box selection

    On a form, I have a 2 combo boxes. One lists EquipmentName, the other Procedure rooms. 2 pieces of equipment are each stationary in its own procedure room. I want to be able to auto fill the procedure room only when either piece of equipment is chosen. For example, if equipment "Fluoro Rm #2"...
  14. P

    if either cell is blank then....else

    I have cells B6 and C6. I need vba code that will put a blank in I6 if either B6 or C6 is blank (has no data/is empty) or will add the value of B6 and C6 if both cells have a number. I have tried IfEmpty, vbNull String and many other post but nothing works. I just tried working with B6 alone (a...
  15. N

    Inserting Rows with IF/THEN in a macro

    I'm trying to figure out how to write the following logic inside a macro: IF W19=Y, THEN INSERT 2 ROWS BELOW R19 IF W19=Y AND X19=Y, THEN INSERT 5 ROWS BELOW R19 Then I would like it to loop to the next row of data and do the same thing (until it gets thru each row of data). For example, if 5...
  16. O

    Macro: If a1 is blank, run macro X, else do nothing

    I am trying to get my macro to do this on open. Check if a1 is empty, if its empty run another macro (which is an input box to put something IN a1), but if A1 has something in it, DO NOTHING. I keep getting errors, saying I'm not formulating my if statements correctly. :confused: This is...
  17. L

    If Then Function Needed to Skip Code if File Exists in Certain Location

    I have several template files that I plan to add the following code to: Private Sub Workbook_BeforeClose(Cancel As Boolean) Dim fname As String Dim MyDate Dim MyMonth MyDate = Date MyMonth = Month(MyDate) Sheet1.Protect "123" Sheet2.Protect "123"...

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top