Consulting

Results 1 to 3 of 3

Thread: Input boxes to change row each time

  1. #1
    VBAX Regular
    Joined
    May 2015
    Posts
    34
    Location

    Input boxes to change row each time

    Hi,
    What i am trying to achieve with these text boxes is for each time the code runs i want it to search column A for the next blank field or automatically use the next row each time it runs. Column A will always be a DATE. The current next available row is row 13, the next time i run the code i want the data in row 14, then 15 and so on.

    You will see in the code that not every column requires data inputting, I have done the easy part

    Probably a easy fix for the Guru's but any help greatly appreciated


    Private Sub Worksheet_Activate()
    Sheets("Supercentre").Select
    Dim InputValue As Variant
    InputValue = InputBox("Date")
    Range("A13") = InputValue
    InputValue = InputBox("Store")
    Range("B13") = InputValue
    InputValue = InputBox("£ Counted")
    Range("C13") = InputValue
    InputValue = InputBox("Expected Units")
    Range("D13") = InputValue
    InputValue = InputBox("Actual Units")
    Range("E13") = InputValue
    InputValue = InputBox("Warehouse Units")
    Range("G13") = InputValue
    InputValue = InputBox("George Units")
    Range("I13") = InputValue
    InputValue = InputBox("CPH")
    Range("K13") = InputValue
    InputValue = InputBox("Crew Size")
    Range("M13") = InputValue
    InputValue = InputBox("Net Error Rate %")
    Range("N13") = InputValue
    InputValue = InputBox("Gross Error Rate %")
    Range("O13") = InputValue
    InputValue = InputBox("SKU Error")
    Range("P13") = InputValue
    InputValue = InputBox("Core Error")
    Range("Q13") = InputValue
    InputValue = InputBox("Off The Floor Time")
    Range("R13") = InputValue
    InputValue = InputBox("Live Comps")
    Range("S13") = InputValue
    InputValue = InputBox("Pallets")
    Range("T13") = InputValue
    InputValue = InputBox("Rails")
    Range("U13") = InputValue
    End Sub
    Last edited by Aussiebear; 04-24-2023 at 05:11 AM. Reason: Adjusted the code tags

  2. #2
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    I did the first two to show you how.

    Option Explicit 'Put at top of all code Modules
    
    Private Sub Worksheet_Activate()
         
     Dim NR As String 'Next Row
        Sheets("Supercentre").Select
        NR = CStr(Cells(Rows.Count, 1).End(xlUp).Row + 1)
         
        Range("A" & NR) = InputBox("Date")
        Range("B" & NR) = InputBox("Store")
        'Continue As above
    
    
        
        'Below not done
        InputValue = InputBox("£ Counted")
        Range("C13") = InputValue
        InputValue = InputBox("Expected Units")
        Range("D13") = InputValue
        InputValue = InputBox("Actual Units")
        Range("E13") = InputValue
        InputValue = InputBox("Warehouse Units")
        Range("G13") = InputValue
        InputValue = InputBox("George Units")
        Range("I13") = InputValue
        InputValue = InputBox("CPH")
        Range("K13") = InputValue
        InputValue = InputBox("Crew Size")
        Range("M13") = InputValue
        InputValue = InputBox("Net Error Rate %")
        Range("N13") = InputValue
        InputValue = InputBox("Gross Error Rate %")
        Range("O13") = InputValue
        InputValue = InputBox("SKU Error")
        Range("P13") = InputValue
        InputValue = InputBox("Core Error")
        Range("Q13") = InputValue
        InputValue = InputBox("Off The Floor Time")
        Range("R13") = InputValue
        InputValue = InputBox("Live Comps")
        Range("S13") = InputValue
        InputValue = InputBox("Pallets")
        Range("T13") = InputValue
        InputValue = InputBox("Rails")
        Range("U13") = InputValue
         
    End Sub
    This would be a great place for a UserForm.
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  3. #3
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,646
    or
    Sub M_snb()
      Sheets("Supercentre").Cells(Rows.Count, 1).End(xlUp).Offset(1).Resize(, 3) = Array(InputBox("nr 1", "Snb"), InputBox("nr 2", "Snb"), InputBox("nr 3", "Snb"))
    End Sub

Posting Permissions

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