Results 1 to 6 of 6

Loop to add string to bottom of a variable column

Threaded View

  1. #1
    Registered User
    Join Date
    06-06-2012
    Location
    Washington DC
    MS-Off Ver
    Excel 2007
    Posts
    23

    Loop to add string to bottom of a variable column

    Hey guys,

    So I have a drop down menu on a worksheet, with values that match up to columns on the same sheet. What I'm trying to do is when a user chooses a value from the dropdown menu and clicks the "run" button, a string (in this case "x") will be placed in the first blank row of the column that corresponds with the value of the dropdown menu.

    I've had limited success so far, as I can get the "x" to appear in different places based on the selection in the dropdown menu, just no where close to where I want it to be.

    The workbook is attached if anyone could provide some insight or suggestions or point out my mistakes.

    Thanks

    Here is some of the code as well

    
    Sub test()
    
    Dim str As String
    Dim a As Integer
    Dim onoff As Integer
    Dim c As Integer
    With Worksheets("Sheet1")
    Dim NextEmptySubCat As Range
    Dim rng As String
    
    str = Range("J2").Value
    a = 1
    onoff = 1
    
    Do Until .Cells(1, a).Value = "" Or onoff = 0
    If .Cells(1, a).Value = str Then
    rng = a
    Set NextEmptySubCat = Range(str & 2).End(xlUp).Offset(0, 1)
    
    NextEmptySubCat.Value = "x"
    onoff = 0
    Else
     a = a + 1
     End If
    Loop
    
    End With
    
    
    
    
    End Sub
    Attached Files Attached Files

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