elseif

  1. 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...
  2. 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 =...
  3. 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...
  4. 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 =...
  5. 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...
  6. 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...
  7. 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...
  8. 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...
  9. 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...
  10. 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...
  11. 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...
  12. E

    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...
  13. 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...
  14. 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...
  15. 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...
  16. J

    For each and If with worksheet function

    Trying to find time gaps based off each cell and its offset (the next cell down) in a dynamic range. My error message right now is 'object required' in the if statement. For Each cell In picks() If WorksheetFunction.Abs(cell.Offset(-1, 0).Value - cell.Value) > 0.02083 Then do something ElseIf...
  17. G

    VBA Code for not to Create/Copy Duplicate Rows

    Hi friends, I have created a workbook of 6 sheets who's VBA code I have writted is, Sub CopyDataBasedOnStatusCondtion() Dim lRow, cRow As Long lRow = Sheets("Sheet1").Range("A50000").End(xlUp).Row For j = lRow To 1 Step -1 If Sheets("Sheet1").Range("B" & j) = "9265553826"...
  18. C

    Help with simple routine

    I will never figure this stull out! Must be brain dead....Keep getting Else without If line 3 If Delete_Lst = Empty Then End If ElseIf Delete_Lst = vbNo Then Exit Sub ElseIf Delete_Lst = vbYes Then Delete_List Else ' End If Thanks in advance!
  19. N

    Is there a better way to make my code less tedious?

    Hi guys, I am making a datasheet for a power substation and I created a number pad that has a command button on it called "Next" what I want this button to do is every time it is clicked it will automatically go to a specific cell and then be filled out. As of right now I do have code that works...
  20. D

    Running a Macro up Pressing the Numeric Enter Key

    Th following code performs flawlessly. The code is in a sheet module as I do not wish for it to run throughout the entire workbook. The code calls for cell selection anytime a change is made to certain cells. I would like for the cell selections to be made upon pressing the numeric enter key...

Some videos you may like

This Week's Hot Topics

  • Importing multiple excel files into one spreadsheet
    Hi, I'm trying to import multiple excel files (with the same format into a single spreadsheet) so that each day's file is listed underneath the...
  • find many based on a certain criteria
    good evening, I hope someone can help me? I have a workbook sheet 2 contains lots of data.... I would like to be able to find anything on sheet...
  • How to copy multiple rows using If
    Hi all, I'm very new to VBA and have written this simple code to copy certain cells if a certain cell within that row contains any data. I need...
  • VBA If statement
    Dear All, I have two dates, where I'd like a message box to pop, if the dates are between this criteria. [CODE] sDate1 = #10/1/2019#...
  • Text Format
    I have a sheet for user to keyin the data. The format of the data can be 451 / 1903, 0012 / 9908 or 00287 / 0099. The number after the "/" is...
  • Syntax errors
    Good Morning, Trying to compile a workbook, I keep getting a few errors. Here are the first two: [code=rich]Syntax Error: Function...
Top