+ Reply to Thread
Results 1 to 4 of 4

Pass value of Object to String

Hybrid View

Rick_Stanich Pass value of Object to String 06-05-2012, 11:08 AM
Rick_Stanich Re: Pass value of Object to... 06-05-2012, 11:25 AM
Pichingualas Re: Pass value of Object to... 06-05-2012, 11:26 AM
Rick_Stanich Re: Pass value of Object to... 06-06-2012, 10:43 AM
  1. #1
    Forum Contributor Rick_Stanich's Avatar
    Join Date
    11-21-2005
    Location
    Ladson SC
    MS-Off Ver
    Office365
    Posts
    1,177

    Pass value of Object to String

    SLogin2 is a string
    sh7CellG is an Object (according to Error 424, Object required)

    Im trying to pass the value of sh7CellG.Offset(0,1) to sLogin2

    When I check the value of sh7CellG.Offset(0,1) via msgbox, its exactly what it should be.
    So how do I pass the value of sh7CellG.Offset(0,1) to sLogin2?
        With Sheets("Misc data")
            'Loop thru Column F
            sh7LastRowG = .Cells(Rows.Count, "G").End(xlUp).Row
            Set sh7RangeG = .Range("G1:G" & sh7LastRowG)
        End With
    
        For Each sh7CellG In sh7RangeG
            If sh7CellG = sLogin Then
                Do While sLogin <> sLogin    ' ""
                    MsgBox "You must enter your Intitals, initials must be approved! (Caps only!)"
                    sLogin = InputBox("Enter Initials here (Caps only!)")
                Loop
    
                MsgBox sh7CellG.Offset(0, 1)  'for testing
                sLogin2 = sht7CellG.Offset(0,1)  <-----Offending line of code "error 424"
                Call Button_Controls.Buttons_Enabled
            End If
        Next sh7CellG
    (Ref: http://www.excelforum.com/excel-prog...e-dynamic.html)
    Last edited by Rick_Stanich; 06-05-2012 at 11:10 AM.
    Regards

    Rick
    Win10, Office 365

  2. #2
    Forum Contributor Rick_Stanich's Avatar
    Join Date
    11-21-2005
    Location
    Ladson SC
    MS-Off Ver
    Office365
    Posts
    1,177

    Re: Pass value of Object to String

    Cant count how many times I changed
    "sLogin2 = sh7cellG.Offset(0, 1)"
    to
    "sLogin2 = sh7cellG.Offset(0, 1).Value"
    and had it fail.
    Until I set the msgbox to "sLogin2 = sh7cellG.Offset(0, 1).Value", now it works all the time?
    Oh well, solved is solved.

  3. #3
    Forum Contributor
    Join Date
    02-07-2012
    Location
    MIA
    MS-Off Ver
    Excel 2007, 2010
    Posts
    429

    Re: Pass value of Object to String

    Small error that might be causing your problem:

        With Sheets("Misc data")
            'Loop thru Column F
            sh7LastRowG = .Cells(Rows.Count, "G").End(xlUp).Row
            Set sh7RangeG = .Range("G1:G" & sh7LastRowG)
        End With
    
        For Each sh7CellG In sh7RangeG
            If sh7CellG = sLogin Then
                Do While sLogin <> sLogin    ' ""
                    MsgBox "You must enter your Intitals, initials must be approved! (Caps only!)"
                    sLogin = InputBox("Enter Initials here (Caps only!)")
                Loop
    
                MsgBox sh7CellG.Offset(0, 1)  'for testing
                sLogin2 = sh7CellG.Offset(0,1)  <-----Offending line of code "error 424" you had sht instead of sh
                Call Button_Controls.Buttons_Enabled
            End If
        Next sh7CellG
    .?*??)
    `?.???.?*??)?.?*?)
    (?.?? (?.?
    Pichingualas <---
    ??????????????????????????

    Wrap your code with CODE TAGS.
    Thank those who helped you, Don't forget to add to their REPUTATION!!! (click on the star below their post).
    Please mark your threads as [SOLVED] when they are (Thread Tools->Mark thread as Solved).

  4. #4
    Forum Contributor Rick_Stanich's Avatar
    Join Date
    11-21-2005
    Location
    Ladson SC
    MS-Off Ver
    Office365
    Posts
    1,177

    Re: Pass value of Object to String

    Thank you!

+ 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