+ Reply to Thread
Results 1 to 4 of 4

storage automation

Hybrid View

  1. #1
    Registered User
    Join Date
    11-03-2020
    Location
    Norway
    MS-Off Ver
    Excel
    Posts
    45

    storage automation

    Hello. i`ve made a storage excel worksheet that we use at the factory i work at, but i want to automate it a little. and then my question is: is it possible if we Scan a number and then autoselect a cell in exel ? with some condition`s .. lets say that product number 850 will only be placed in A3 to D8, and the cell needs to be empty ofc, and that it counts the scanned pallets and posts the number of pallets up to 15 on the row it selects? after 15 it changes to another cell since out storage got 15 pallets pr row.. i attaced the store program, today we write the information in sheet 1 , and it shows in sheet 2
    Attached Files Attached Files

  2. #2
    Forum Contributor
    Join Date
    08-22-2017
    Location
    USA
    MS-Off Ver
    2016 WINDOWS and MAC
    Posts
    294

    Re: storage automation

    Hi,

    your problem is far too confusing and unfamiliar to have any realistic help. You need to simplify it and post a sample of precisely what you need.

  3. #3
    Forum Expert millz's Avatar
    Join Date
    08-14-2013
    Location
    Singapore
    MS-Off Ver
    Excel, Access 2016
    Posts
    1,694

    Re: storage automation

    If I understood you correctly, try placing this together in your Worksheet_Change event codes, right at the top.

    Private Sub Worksheet_Change(ByVal Target As Range)
        Dim f As Range, s As String, a As String, i As Long, j As Long, placed As Boolean, alerts As Boolean
        
        'set to false to disable MsgBoxes
        alerts = True
        
        If Target.Count = 1 And Target.Value <> "" Then
            If Not Intersect(Target, Range("BB2")) Is Nothing Then
                s = Target.Value
                placed = False
                Set f = Range("B:R").Find(s, lookat:=xlWhole) 'find for scanned code within columns B:R
                If Not f Is Nothing Then
                    a = f.Address
                    If f.Offset(1).Value >= 15 Then 'full, find next
                        Do
                            Set f = Range("B:R").Find(s, after:=f, lookat:=xlWhole)
                            If Not f Is Nothing Then
                                If f.Offset(1).Value < 15 Then 'not full, add 1
                                    placed = True
                                    f.Offset(1).Value = f.Offset(1).Value + 1
                                    If alerts Then MsgBox "[ " & s & " ] stored at cell [ " & f.Address(0, 0) & " ]", vbInformation Or vbOKOnly
                                End If
                            End If
                        Loop While a <> f.Address
                        If Not placed Then GoTo fNext 'no empty storage left, find next avail space
                    Else 'not full, add 1
                        placed = True
                        f.Offset(1).Value = f.Offset(1).Value + 1
                        If alerts Then MsgBox "[ " & s & " ] stored at cell [ " & f.Address(0, 0) & " ]", vbInformation Or vbOKOnly
                    End If
                Else 'none found, add to next avail space
    fNext:
                    For i = 2 To 20 Step 2 'rows loop
                        For j = 2 To 18 'columns B:R
                            If Cells(i, j).Value = "" Then
                                placed = True
                                Cells(i, j).Value = s
                                Cells(i + 1, j).Value = 1
                                If alerts Then MsgBox "[ " & s & " ] stored at cell [ " & Cells(i, j).Address(0, 0) & " ]", vbInformation Or vbOKOnly
                            End If
                            If placed Then Exit For
                        Next
                        If placed Then Exit For
                    Next
                    If alerts And Not placed Then MsgBox "No more available storage!", vbCritical Or vbOKOnly
                End If
                
                Range("BB2").Select
                If placed Then Target.Value = ""
            End If
        End If
    
    
        ...
        ... your existing codes here
        ...
    
    End Sub
    The cell the code is reading is BB2. You have to unprotect your sheet and unlock this cell first, since it's locked and protect in your file. You can edit it to be another cell you like.
    The idea is to have this as the "input textbox", so have this cell selected, then scan your codes. It will be searched for a match, and sees the number of pallets below it, adds 1 OR find another match or for a next empty cell if it's already 15. I've added explanatory comments to help you understand the codes.
    Last edited by millz; 12-24-2020 at 01:01 PM.
    多么想要告诉你 我好喜欢你

  4. #4
    Registered User
    Join Date
    11-03-2020
    Location
    Norway
    MS-Off Ver
    Excel
    Posts
    45

    Re: storage automation

    this was an enormous job !!:D wow. i will have to sit down and look at it tomorrow and try to understand it! so i will replay more tomorrow!! thank you soo much so:D

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Data storage
    By jatolo in forum Excel General
    Replies: 8
    Last Post: 04-04-2020, 10:18 AM
  2. Storage calculation
    By deep123 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 08-01-2016, 05:17 AM
  3. data storage
    By david90 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-11-2012, 03:37 PM
  4. Going from Storage to a Count
    By Phlyers18 in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 09-14-2011, 08:00 PM
  5. Data Storage
    By gregory.barrett in forum Excel General
    Replies: 3
    Last Post: 03-30-2006, 05:25 PM
  6. Variable Storage
    By gti_jobert in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-08-2006, 07:35 AM
  7. Can not open macro storage
    By Fred in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-15-2005, 01:06 AM

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