Consulting

Results 1 to 4 of 4

Thread: Putting data where you want it!!

  1. #1

    Putting data where you want it!!

    Sub Enter_Agreement_details()
    Dim Iput As String, Data As Variant, i As Integer
    Sheet3.Select
    Range("A1").End(xlDown).Offset(1, 0).Select
    Data = Array("Agreement Number", "Parent Company", "Title", "First Name", "Surname", "Street", "Town", "City", "County", "Post Code", "Phone", "Fax", "E-Mail", "Application Received", "UNA To Site", "UNA Received From Site", "UNA To DEFRA", "DEFRA Approved")
    For i = LBound(Data) To UBound(Data)
    Iput = InputBox(".:: p l e a s e  e n t e r  f o l l o w i n g  d a t a ::.  " & Chr(10) & Chr(10) & Data(i), Data(i))
    Next i


    Ok, what I would like the above to do is take the data it receives from the inputbox and place it on the worksheet starting at the point selected by the code [VBA]Range("A1").End(xlDown).Offset(1, 0).Select[/VBA] so for arguments sake say it selects A10 then the following data should then go in B10, C10, D10 etc until the array has completed asking for data.

    Hope this Makes sense?

    Cheers folks!!

  2. #2
    Knowledge Base Approver
    The King of Overkill!
    VBAX Master
    Joined
    Jul 2004
    Location
    Rochester, NY
    Posts
    1,727
    Location
    Hi,
    I changed your sub a little bit, should do what you want!

    Sub Enter_Agreement_details()
        Dim Iput As String, Data As Variant, i As Long, iUB As Long, Answers() As String
    Data = Array("Agreement Number", "Parent Company", "Title", "First Name", _"Surname", "Street", "Town", "City", "County", "Post Code", "Phone", "Fax", 
         "E-Mail", "Application Received", "UNA To Site", "UNA Received From Site", _
         "UNA To DEFRA", "DEFRA Approved")
    iUB = UBound(Data)
        ReDim Answers(iUB)
    For i = 0 To iUB
            Iput = InputBox(".:: p l e a s e  e n t e r  f o l l o w i n g  d a t a ::.  " _
             & Chr(10) & Chr(10) & Data(i), Data(i))
            Answers(i) = Iput
        Next i
    With Sheet3.Range("A1").End(xlDown)
         Range(.Offset(1, 0), .Offset(1, iUB)) = Answers
        End With
    End Sub
    Matt

  3. #3
    VBAX Master Norie's Avatar
    Joined
    Jan 2005
    Location
    Stirling, Scotland
    Posts
    1,831
    Location
    Does this work?
    Option Base 1
    Sub Enter_Agreement_details()
    Dim Iput As String, arrData As Variant, i As Integer
    Dim NextRow As Long
    	
    	NextRow = Sheet3.Range("A65536").End(xlUp).Row + 1
    	 
    	arrData = Array("Agreement Number", "Parent Company", _
    					"Title", "First Name", "Surname", "Street", _
    					"Town", "City", "County", "Post Code", "Phone", _
    					"Fax", "E-Mail", "Application Received", "UNA To Site", _
    					"UNA Received From Site", "UNA To DEFRA", "DEFRA Approved")
    	 
    	For i = LBound(arrData) To UBound(arrData)
    		 
    		Iput = InputBox(".:: p l e a s e  e n t e r  f o l l o w i n g  d a t a ::.  " & Chr(10) & Chr(10) & arrData(i), arrData(i))
    		Sheet3.Cells(NextRow, i) = Iput
    	Next i
    	
    End Sub

  4. #4
    Ok, both work splendidly, thank you kindly!!

    Top work, saved me pulling anymore hair out!!

Posting Permissions

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