How to creat a macro to generate a barcode in excel by clicking a button?

fmoaveni

New Member
Joined
Nov 23, 2015
Messages
38
Hello,
I am using microsoft office excel 2013. I have googled everything I can think of and all I can find are ways to create barcodes from numbers I type in. I am trying to see if it is possible to generate barcodes with random numbers so that it will not create duplicate barcodes. Maybe if it goes until 1,000,000 possibilities then that would be fine to duplicate.


I have an excel workbook I am creating and on sheet1 I want it to have a cell, let's call it "B20", that will automatically generate a barcode number and picture. This barcode should generate every time I click the macro button. I will have other information that I input via a popupbox that when I click "ok", will go directly to a line on sheet2...The barcode that is generated will also copy to that line....in theory. :D

Before I ask more detailed questions, is this even possible to begin with?

If so, I will post another forum to see if I can get a bit more specific with the task I need to finish.

Is there any other suggestion anyone has if this is not possible? Thank you!


The barcode would be used to keep track of items delivered at the same time. Each time I fill out the form I want to be able to assign them to a barcode so that when I scan the barcode the next time, it will automatically pull the information I need.

Kind Regards,
fmoaveni
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
A barcode is a font. If you need to print a list of barcodes to use, install a barcode font.
Does your number really need to be random or will something that looks random work for you?

Using the row number ensures it won't be repeated on the sheet.
Test the following:
Code:
Sub test()
x = Timer
Selection.Value = "A" & Format(Date, "DDYY") & Selection.Row() & Format(Int(x * 100000), "000000")

Selection.Offset(1).Select

End Sub

If you like it:

Put it in worksheet double- click (with modification for target instead of selection).
Check target intersects the right column
Check target cell is blank
turn off events
Update cell with formula
turn events back on

Edit: thought I'd written the following aleady

Using row in the formula ensures non repetition in the same sheet. I f you need it in more than one sheet add
ActiveSheet.Index somewhere.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,976
Messages
6,122,539
Members
449,088
Latest member
RandomExceller01

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