Results 1 to 4 of 4

Thread: [Resolved]I can't seem to get the activeCell to work with this variable

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2005
    Posts
    14

    Resolved [Resolved]I can't seem to get the activeCell to work with this variable

    VB Code:
    1. Option Explicit
    2.  
    3. Sub updateReturn()
    4. '
    5. ' updateReturn Macro
    6. ' Macro recorded 07/14/2005 by
    7. '
    8. ' Keyboard Shortcut: Ctrl+r
    9. '
    10.  
    11. Range("A5").Select
    12.    
    13.    
    14.     Cells.Find(What:="F00", after:=activeCell, LookIn:=xlFormulas, Lookat:= _
    15.     xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:= _
    16.     False, SearchFormat:=False).activate
    17.    
    18.     Dim Issue As String
    19.     Dim Date1 As String
    20.    
    21.     Issue = Range("B3").Value
    22.     Date1 = Range("B2").Value
    23.  
    24.     Do Until activeCell.Value = "F00----"
    25.    
    26.         If activeCell.Value = "F00" Then
    27.             Cells.Find(What:="F00", after:=activeCell, LookIn:=xlFormulas, Lookat:= _
    28.             xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:= _
    29.             False, SearchFormat:=False).activate
    30.         [B]
    31.         Else
    32.             Dim carry As String
    33.             Dim quantity As Integer
    34.            
    35.             carry = activeCell.Value
    36.             activeCell.Offset([0], [2]).activate
    37.             quantity = activeCell.Value
    38.             activeCell.Offset([0], [-2]).activate
    39.            
    40.             If quantity = "1" Then
    41.                 [/B]
    42.                 Windows("Equipment Log.xls").activate
    43.            
    44.                 Dim finish As Boolean
    45.                 Dim index As Integer
    46.                 index = 1
    47.                 finish = False
    48.            
    49.                 Do Until finish = True
    50.            
    51.                     If index = 12 Then
    52.                
    53.                         Dim Msg, Style, Title, Help, Ctxt, Response, MyString
    54.                         Msg = "YTG Stock #" + carry + " Not Found"    ' Define message.
    55.                         Style = vbOKOnly + vbExclamation + vbDefaultButton1    ' Define buttons.
    56.                         Title = "Stock Number Not Found"    ' Define title.
    57.                         Help = "DEMO.HLP"    ' Define Help file.
    58.                         Ctxt = 1000    ' Define topic
    59.                         ' context.
    60.                         ' Display message.
    61.                          Response = MsgBox(Msg, Style, Title, Help, Ctxt)
    62.                    
    63.                         If Response = vbYes Then    ' User chose Yes.
    64.                              MyString = "Yes"    ' Perform some action.
    65.                         End If
    66.  
    67.                         finish = True
    68.                     Else
    69.                
    70.                         Worksheets(index).activate
    71.                
    72.                         Range("B4").Select
    73.                
    74.                         Do Until activeCell.Value = "" Or finish = True
    75.                    
    76.                             If activeCell.Value = carry Then
    77.                                 activeCell.Offset([0], [3]).activate
    78.                                 activeCell = Date
    79.                                 finish = True
    80.                             Else
    81.                                 activeCell.Offset([1], [0]).activate
    82.                             End If
    83.        
    84.                         Loop
    85.                         index = index + 1
    86.                
    87.                    
    88.                     End If
    89.                 Loop
    90.                
    91.                 Else
    92.                
    93.                 End If
    94.                
    95.                 Windows("Material Reconciliation Slips.xls").activate
    96.            
    97.                 Cells.Find(What:="F00", after:=activeCell, LookIn:=xlFormulas, Lookat:= _
    98.                 xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:= _
    99.                 False, SearchFormat:=False).activate
    100.                
    101.            
    102.        
    103.         End If
    104.        
    105.        
    106.    
    107.         Loop
    108.    
    109. 'Windows("Equipment Log.xls").activate
    110. 'Worksheets(1).activate
    111. 'Windows("Material Reconciliation Slips.xls").activate
    112. End Sub


    The problem seems to be in the bolded section. I can't get into that if statement because it isn't recognizing the variable in the quantity or something. On the actual spreadsheet there is a "1" in that location so it should be picking it up.

    Is there something obvious I'm doing wrong here? It all looks logical to me but it isn't working.
    Last edited by Sasaraii; Jul 19th, 2005 at 01:26 PM.

  2. #2
    Frenzied Member
    Join Date
    Nov 2001
    Location
    Mass USA
    Posts
    1,674

    Re: I can't seem to get the activeCell to work with this variable

    Try Activecell.Text instead of Value.

  3. #3
    PowerPoster lintz's Avatar
    Join Date
    Mar 2003
    Location
    The 19th Hole
    Posts
    2,697

    Re: I can't seem to get the activeCell to work with this variable

    Instead of...

    VB Code:
    1. activeCell.Offset([0], [2]).activate
    2.             quantity = activeCell.Value
    3.             activeCell.Offset([0], [-2]).activate


    try...

    VB Code:
    1. activeCell.Offset([0], [2]).Select
    2.             quantity = activeCell.Value
    3.             activeCell.Offset([0], [-2]).Select

  4. #4

    Thread Starter
    New Member
    Join Date
    Jun 2005
    Posts
    14

    Re: I can't seem to get the activeCell to work with this variable

    Thanks guys, I figured out the problem.

    Turns out my search function was looking under the formula for the number but I actually needed it to check then Value of the cell, not the formula.

    Works now

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