+ Reply to Thread
Results 1 to 36 of 36

Quicker way to enter in multiple vba if statements

Hybrid View

jubangy Quicker way to enter in... 05-17-2008, 07:30 AM
mudraker jubangy Please take a... 05-17-2008, 07:51 AM
jubangy Sorry about that, I hope the... 05-17-2008, 08:17 AM
royUK Why are you using VBA,... 05-17-2008, 08:30 AM
jubangy ? Could you elaborate a... 05-17-2008, 09:01 AM
  1. #1
    Registered User
    Join Date
    02-27-2005
    Posts
    35

    Quicker way to enter in multiple vba if statements

    I have attached a copy of my monthly work schedule. Sorry if it looks too noobish but I am.
    The question I have is on the schedule right now, it uses to of the same schedule, one is called request off and the other the final. The request off right now is where all changes are made, and they reflect on the final. I did it this way because I could not figure out how to make the cells autofill according to the day of the week, like if it was friday i needed it to fill in the shifts and normal days off automatically. What I am trying to do now is eliminate the need for the second schedule, the request off one. I think I have figured out how to have the cells autofilled according to the day of the week, and also let the user enter in other stuff such as sick, vacation or whatever, and have it autofill if the cell is left blank, using vba. this is what i have so far, and it is working I was just wondering if it was possible to set it up for a range of cells instead of having to enter each one in manually.


    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Range("h1").Value <= 0 Then
    Range("h1") = Range("i1")
    End If
    
    If Range("h2").Value <= 0 Then
    Range("h2") = Range("i2")
    End If
    
    If Range("h3").Value <= 0 Then
    Range("h3") = Range("i3")
    End If
    
    End Sub
    example.zip
    Any and all help is greatly appreciated. Thanks.
    Last edited by jubangy; 05-17-2008 at 08:15 AM. Reason: Added Attachment

  2. #2
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983
    jubangy

    Please take a couple of minutes and read the Forum Rules then edit your thread title by following the instructions in the rules (Rule 1)
    Please Read Forum Rules Before Posting
    Wrap VBA code by selecting the code and clicking the # icon or Read This
    How To Cross Post politely

    Top Excel links for beginners to Experts

    If you are pleased with a member's answer then use the Scales icon to rate it
    If my reply has assisted or failed to assist you I welcome your Feedback.

  3. #3
    Registered User
    Join Date
    02-27-2005
    Posts
    35
    Quote Originally Posted by mudraker
    jubangy

    Please take a couple of minutes and read the Forum Rules then edit your thread title by following the instructions in the rules (Rule 1)
    Sorry about that, I hope the title is now more appropriate as I really was not/am not to sure how to accurately describe what it is I am asking without a long description.

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Why are you using VBA, looking at the code you've posted I would have thought it was unnecessary.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  5. #5
    Registered User
    Join Date
    02-27-2005
    Posts
    35
    ?
    Could you elaborate a little more?
    I need it so if something is entered into one of the days, that will be the info used, but when the next month comes, when i redo the schedule i need the formula back without having to retype it.

    With the 2 sheets, the request off and the final this isnt a problem but I am trying to eliminate the request off sheet, so when I do the schedule for the following month, the formulas return when i clear the cells.
    for example say in c5 i put in vac, next month when i do the schedule in c5 i need to be able to clear cell c5 and have it use the data from t5.
    Liek i said with the 2 sheets this isnt a problem, but i would liek to get it down to just one.
    Thanks.

  6. #6
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,524
    Quote Originally Posted by jubangy
    ?
    Could you elaborate a little more?
    I need it so if something is entered into one of the days, that will be the info used, but when the next month comes, when i redo the schedule i need the formula back without having to retype it.

    With the 2 sheets, the request off and the final this isnt a problem but I am trying to eliminate the request off sheet, so when I do the schedule for the following month, the formulas return when i clear the cells.
    for example say in c5 i put in vac, next month when i do the schedule in c5 i need to be able to clear cell c5 and have it use the data from t5.
    Liek i said with the 2 sheets this isnt a problem, but i would liek to get it down to just one.
    Thanks.
    Very strange, I thought I attached a code to this thread..
    anyway...

    Try this
    Sub YouKnow()
        Dim r As Range
        Dim c As Range
        Set r = Range("H1", Range("H65536").End(xlUp))
        For Each c In r.Cells
            If c <= 0 Then
                c = c.Offset(0, 1)
            End If
        Next c
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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