Store a number on another sheet

jcaptchaos2

Well-known Member
Joined
Sep 24, 2002
Messages
1,032
Office Version
  1. 365
Platform
  1. Windows
Hello,

I have a workbook where the employee types a number in cell "B16" the worksheet name is "Interface" they then press a macro button which prints out a label. I want to add to the front of that macro to first store that number in the first open cell of another worksheet lets say it's called "Dat". I would like it to be stored in column "B". What else that would be great is if it would check the list in column "B" and if the number is already there throw up a flag of some type.
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Try

Code:
Sheets("Dat").Range("B" & Rows.Count).End(xlUp).Offset(1).Value = Sheets("Interface").Range("B16").Value
If WorksheetFunction.CountIf(Sheets("Dat").Columns("B"), Sheets("Interface").Range("B16").Value) > 1 Then MsgBox "Dup", vbInformation
 
Upvote 0
VoG,

If you don't mind I need a little more help on this, here is my full code and what I would like it to do is stop if that number is already in the list. I added the code you gave me but it still puts the number in column "B" on the "DAT" sheet, I don't need it to do that what I need is for it to stop there and then make the employee type in a different number.
Code:
Sub Packing()
'
' packing Macro
'

'
    Sheets("Dat").Range("B" & Rows.Count).End(xlUp).Offset(1).Value = Sheets("Interface").Range("B16").Value
If WorksheetFunction.CountIf(Sheets("Dat").Columns("B"), Sheets("Interface").Range("B16").Value) > 1 Then MsgBox "You have already used this number", vbInformation

    Range("B2").Select
    Sheets("Packing Slip Label").Select
    ActiveSheet.Unprotect
    ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
        IgnorePrintAreas:=False
     ActiveSheet.Protect
    Sheets("Interface").Select
    Range("B2").Select
End Sub
 
Upvote 0
Maybe like this

Code:
Sub Packing()
'
' packing Macro
'

'
Sheets("Dat").Range("B" & Rows.Count).End(xlUp).Offset(1).Value = Sheets("Interface").Range("B16").Value
If WorksheetFunction.CountIf(Sheets("Dat").Columns("B"), Sheets("Interface").Range("B16").Value) > 1 Then
    MsgBox "You have already used this number" & vbNewLine & "Please enter a unique number", vbInformation
    Sheets("Dat").Range("B" & Rows.Count).End(xlUp).ClearContents
    Exit Sub
End If
Sheets("Packing Slip Label").PrintOut
Range("B2").Select
End Sub
 
Upvote 0
Exactly what I needed, thank you so much for the quick response.
 
Upvote 0

Forum statistics

Threads
1,224,566
Messages
6,179,555
Members
452,928
Latest member
101blockchains

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top