Results 1 to 6 of 6

Thread: [RESOLVED] Access object on a subroutine (casting to string??)

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2015
    Posts
    12

    Resolved [RESOLVED] Access object on a subroutine (casting to string??)

    Hi,
    I have two worksheets with names User_Logins and Users_Table.
    On User_Logins I have info about last logins of a user and who is the current user (Cell F7)
    On Users_Table I have info about all users (first row with data is row10.. A10:A50 usernames , B10:B50 passwords etc)

    Also , I have made a userform in order usser to change password (three textboxes)

    The problem I have is that I know the specific row (loc.row) searching user but on save button I cant access variable.
    I think that loc is defined as object and I can access it as string.

    My code is the following

    Code:
    Dim user As Variant
    Dim pass As Variant
    Dim loc
    Dim RangeUsernames As Variant
    Dim passPassword As Boolean
    
    
    Private Sub CancelButton_Click()
        Call UserForm_Initialize
    End Sub
    
    Private Sub SaveButton_Click()
        Dim locationNewPass As String
        
    	'Checkings here
    
        If passPassword = True Then
            Msg = MsgBox("Password was successfully validated.", vbInformation, "Change Password")
            Unload Me
        
            'Sheets("Users_Table").Range("B11").Value = "5555"    'it works
            'MsgBox (Sheets("Users_Table").Range("B" & loc.row).Value) 'it does not work
            
            MsgBox loc.row
        End If
       
    End Sub
    
    Private Sub UserForm_Initialize()
        oldPassTextBox.Text = ""
        newPassTextBox.Text = ""
        confirmPassTextBox.Text = ""
        oldPassTextBox.SetFocus
     
        
        oldPassTextBox.PasswordChar = "*"
        newPassTextBox.PasswordChar = "*"
        confirmPassTextBox.PasswordChar = "*"
        
        
        passPassword = True
        
        'Find User
        user = Sheets("User_Logins").Range("F7").Value
        
        
        'Define Range of usernames (for instance A10:A50)
        Set WS = Worksheets("Users_Table")
        With WS
            Set LastCellA = .Cells(.Rows.Count, "A").End(xlUp)
        End With
    
        If LastCellA.row = 10 Then
            RangeUsernames = "A10"
        Else
            RangeUsernames = "A10:A" & LastCellA.row
        End If
        
        'Find row of data on Users_Table
        With Sheets("Users_Table").Range(RangeUsernames)
            Set loc = .Find(What:=user, LookIn:=xlFormulas, _
                LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
                MatchCase:=False)
                'If Not loc Is Nothing Then
                   'MsgBox loc.row
                'End If
        End With
        
        pass = loc.Offset(0, 1)
        
    End Sub
    Finally, I have a last question
    Because my local language on excel is greek, when I am trying the code
    Code:
     Dim myday As String 
     myday = Format(now(), "dddd")
    the result is on greek language

    Can I take as result on english ?


    Could you help me please ?
    Thank you
    Last edited by Prokopis; May 25th, 2015 at 02:12 PM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width