Results 1 to 2 of 2

Thread: Form referring to a module
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    Board Regular
    Join Date
    Mar 2004
    Posts
    2,001
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Form referring to a module

    This is complicated to explain, so bear with me please

    I have a for next loop set up as follows

    Code:
    For j = 2 To LastRow Step 1
      
      a = Cells(j, 53)
      
      If a = "1" Then
      
      tcsorting.Show
      
      Else
      
      Cells(j, 8) = Cells(j, 53)
      
    
      End If
      
      Next
    If A = 1 then a form called tc sorting will display

    In this form the user selects a location, this location then must be dumped on the row number......defined by J

    But when it moves to the form it no longer recognises J

    Code:
    Private Sub CommandButton1_Click()
    
    Dim j As Integer
    
    
    
    Cells(j, 8) = travelcentre.Text
    
    
    End Sub

    Any ideas please ?

    Thanks

  2. #2
    MrExcel MVP
    Moderator
    Fluff's Avatar
    Join Date
    Jun 2014
    Location
    Chippenham
    Posts
    28,314
    Post Thanks / Like
    Mentioned
    471 Post(s)
    Tagged
    47 Thread(s)

    Default Re: Form referring to a module

    How about
    Code:
    For j = 2 To LastRow Step 1
      
      a = Cells(j, 53)
      
      If a = "1" Then
      tcsorting.Tag=j
      tcsorting.Show
      
      Else
      
      Cells(j, 8) = Cells(j, 53)
      
    
      End If
      
      Next
    and then
    Code:
    Private Sub CommandButton1_Click()
    
    
    
    
    
    Cells(Me.Tag, 8) = travelcentre.Text
    
    
    End Sub
    - Posting Data try one of these tools
    - Posting guidelines, forum rules and terms of use
    - Read the FAQs

    Running Office 365 on Win 10

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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