UserName lister

 Sub ManageCategoryEntries()

    Dim AllEntriesRange As Range

    Dim CurrentCategoryRange As Range

    Dim UserName As String

    Dim Cell As Range

    Dim UserNameFoundInCurrent As Boolean

    Dim UserNameFoundInAll As Boolean


    ' Define ranges and UserName

    Set AllEntriesRange = Range("C7:L11")

    Set CurrentCategoryRange = Range("C7:C11")

    UserName = Application.UserName

    

    ' Check if there are any empty cells in the CurrentCategoryRange

    If WorksheetFunction.CountBlank(CurrentCategoryRange) = 0 Then

        MsgBox "Entries to this category are closed"

        Exit Sub

    End If

    

    ' Check if UserName is already in CurrentCategoryRange

    UserNameFoundInCurrent = False

    For Each Cell In CurrentCategoryRange

        If Cell.Value = UserName Then

            UserNameFoundInCurrent = True

            Exit For

        End If

    Next Cell

    

    If UserNameFoundInCurrent Then

        MsgBox "Already listed"

        Exit Sub

    End If

    

    ' Search for UserName in AllEntriesRange and remove it if found

    UserNameFoundInAll = False

    For Each Cell In AllEntriesRange

        If Cell.Value = UserName Then

            Cell.Value = ""

            UserNameFoundInAll = True

            Exit For

        End If

    Next Cell

    

    ' Add UserName to the first empty cell in CurrentCategoryRange

    If Not UserNameFoundInCurrent Then

        For Each Cell In CurrentCategoryRange

            If Cell.Value = "" Then

                Cell.Value = UserName

                Exit For

            End If

        Next Cell

    End If

    

    ' If UserName was found and removed from AllEntriesRange, notify the user

    If UserNameFoundInAll Then

        MsgBox "Your entry moved to the category"

    End If

End Sub

COMMENTS

Name

Code,1,Free Stuff,2,History,1,Management & Leadership,2,Security,2,
ltr
item
ManageMag: UserName lister
UserName lister
ManageMag
http://www.managemag.com/2024/07/username-lister.html
http://www.managemag.com/
http://www.managemag.com/
http://www.managemag.com/2024/07/username-lister.html
false
3228987248158602567
UTF-8
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS PREMIUM CONTENT IS LOCKED STEP 1: Share to a social network STEP 2: Click the link on your social network Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy