elseif

  1. S

    Define As String variably using If & ElseIf

    Hi there experts! I have a preexisting VBA code to create and submit data files into a Snowflake Data Warehouse. Now, they'd like me to change the data file names to have a version suffix, to differentiate files in case we need to resubmit them during the month. For example "..._01", "..._02"...
  2. T

    Next without For, End If without Block If

    Hi All, I've moved around my "if" and "end if", as well as the "for" and "next" statements in my code, but I continue to get one of those two errors no matter where I move the statements. Here is my code: Option Explicit Private Sub worksheet_change(ByVal Target As Range) Dim...
  3. T

    VBA conditional searching for entire cell contents

    I am trying to write a VBA module to help me identify the source of an excel file that I am given based on known cell values in the header. For example if ""Service Waiver Acknowledged"" exists in any position of the range A1:Z5 then I know this file came from Software1 whereas if ""AnnivDay""...
  4. I

    How to edit this VBA code include an If statement

    Hello. I have this VBA code to change the values of cells in column D depending on what time are in the cells in column A. 6:15:00's are STG.A01 then increasing in sequential order number wise. STG.A02, STG.A03, etc. 6:45:00's are STG.B. 7:15:00's are STG.C. 7:45:00's are STG.D. 8:15:00's are...
  5. F

    If, ElseIf statements (multiple)

    Is it possible to have an ElseIf statement on a single line? An example is shown but each statement is on two lines. Tried the following but did not work. If IsInArray(Character, Array01) = True Then: Increment = 1 Function Size(Character As String) As Double Dim Increment As Double...
  6. R

    VBA not working out

    Hi, I am fairly new to excel VBA and I have tried a bunch of different methods. I am trying to highlight only column I and J, if it is not blank, but also trying to highlight the cells with different colors based on values column G. For now, the code that I have inputted makes the excel change...
  7. J

    placing "X" at offset point

    Hi everyone!! The following code had been working; Sub Prodigal()Dim x As Range If IsEmpty(Sheets("Watched").Range("I2")) = True Then Sheets("Watched").Range("I2") = "X" Else If IsEmpty(Sheets("Watched").Range("I2")) = False Then Set x =...
  8. N

    Simplifying this Macro Help

    Howdy all, I need some assistance to make this macro more streamlined. I have a worksheet that has certain cells that are input cells, but I want to have text in the cell that reads "Please Select Program" What my simple macro skills have allowed me to do is the following: The code is input...
  9. A

    Creating Multiple Calendar

    This code create a calendar. I would like to create calendars for the whole year. The calendar setup example is listed below. How can I achieve this? Thanks Sub CreateCalendar() Dim csheet As Worksheet Set csheet = ThisWorkbook.Sheets("Sheet1") selDate = [b2] fMon =...
  10. J

    how to shorten this one ??

    Private Sub awp() Set wks = Sheet9 If wks.Range("I3").Offset(0, 0).Text = "Yes" Then obYes.Value = True ElseIf wks.Range("I3").Offset(0, 0).Text = "No" Then obNo.Value = True ElseIf wks.Range("I3").Offset(0, 0).Text = "N/A" Then obNa.Value = True End If If...
  11. J

    for each loop

    Private Sub awp() Set wks = Sheet9 If wks.Range("I3").Offset(0, 0).Text = "Yes" Then obYes.Value = True ElseIf wks.Range("I3").Offset(0, 0).Text = "No" Then obNo.Value = True ElseIf wks.Range("I3").Offset(0, 0).Text = "N/A" Then obNa.Value = True End If If...
  12. J

    looping

    can someone help me to loop this ? Dim wks As Worksheet Dim addnew As Range Dim addup(15) As Double Set wks = Sheet9 Set addnew = wks.Range("AG3").Offset(0, 0) If ecYes.Value = True Then addnew.Offset(0, 1).Value = ecYes.Caption ElseIf ecNo.Value = True...
  13. J

    VBA Close With Save Causes Runtime Error

    can someone help me ?? what code who runs first to my userform_initialize.. Private Sub adddata_Click() Dim wks As Worksheet Dim addnew As Range Dim addup(15) As Double Set wks = Sheet9 Set addnew = wks.Range("AG3").Offset(0, 0) If ecYes.Value = True Then...
  14. N

    Comparing color indexes in two different sheets?

    Hello, I recently got introduced to VBA and I will say I am completely new to programming. I have 3 sheets Sheet1 - Contains Current weeks data, I just call it "Curr" Sheet2 - Contains Previous weeks data, I call it "Prev" Sheet3 - Contains the results, I call it "Result" where I compare the...
  15. B

    printing code needs edited

    As you can tell the code below prints of the sheets that contain data in them. The trouble im having is about half way down there are some print settings that are only working on the active sheet. Im unsure what to replace the active sheet with so it will apply all the printer settings listed to...
  16. Y

    Combine two Subs into one

    Hi all. I have two private subs, they work when i run them alone but i am having trouble combining them The function of the code is id you select a value in d15 it would unhide rows depending on the value so select the number one and it hides the 14 rows below Then move onto d16 and the axact...
  17. excelbytes

    Object Qualifies

    I am new to VBA. I am trying to change the background color of a text box based on another cell value. I am getting a Runtime error 424 Object required error. Here is my code - what am I doing wrong? Public Sub TextBoxColor() If Worksheets("Sheet1").Range("E1").Value = "Name" Then...
  18. F

    VBA: Double click choices from a range

    I'm using a doubleclick event with the code below and all works well with the range of G2:G5. At times the range could be longer, but not sure how to rearrange this to accomodate for say a range of G2:G10. The range contains text. If Target.Address = "$H$6" Then If Target.Value...
  19. S

    Multiple Scripting Libraries?

    I don't think this is possible, but I'm sure there is a way to do what i'm trying to do. I have a user form. The form has 2 checkboxes, 2 option buttons, 2 text boxes, and 1 combo box. The text boxes are enabled/disabled by the checkboxes. The contents of the combo box change based on the two...
  20. E

    Elseif issue

    Not sure why this gets an error. It seems pretty simple. Error occurs at the ElseIf "Application.GoTo ActiveWorkbook.Sheets("Scores").Cells(3, 1)" line I replaced it with the App GoTo line above and if functions as it should, so its not liking the "Scores" name. Spelling correct, same...

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