Entering a set number whenever a criteria is met

dpaton05

Well-known Member
Joined
Aug 14, 2018
Messages
2,352
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
I have a spreadsheet that has many quotes in it.

  • Each line is a quote and the quotes all have a request number.
  • The quotes start in row 4 and go down from there with heading/title etc above
  • Column C has the request number
  • I need a way to be able to search for all the request numbers and enter a purchase order number for that quote
  • The purchase order number is in column B
At the top of the spreadsheet, I have 2 cells, to enter the purchase order number aND one to enter the request number.
  • The cell to enter the request number is in F1 and the cell to enter the purchase order number is in H1.
How would I go about entering a request number in F1 and a purchase order number in H1 and I need the purchase order number to be copied to every quote with that request number, as I am not sure?
 
Last edited:
I am glad that you have determined why some values did not match up
- some numbers are numbers, other numbers are text (not an uncommon issue!)
Later, I will provide you with some basic code to scan monthly sheets to identify those "rogue" entries
Place code in a standard module and run
- new sheet added
- type of value in each cell (in Req# column) in each sheet listed
- data filter enabled to simplify filtering by sheet and type of value

The code is a bit lazy - it assumes that if value not text then it's a number (but should be OK for this job)
VBA Code:
Sub IsItANumber()
    Dim sh, ws As Worksheet, temp As Worksheet, ReqRng As Range, Cel As Range, CellContent As Variant, a As String
    Set temp = Sheets.Add(before:=Sheets(1))
    temp.Range("A1:C1") = Array("Sheet", "Cell", "Type")
    For Each sh In Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December")
        Set ws = Sheets(sh)
        Set ReqRng = ws.Range("C4", ws.Range("C" & Rows.Count).End(xlUp))
            For Each Cel In ReqRng
                CellContent = Cel.Value
                If VarType(CellContent) = 8 Then a = "text" Else a = "number"
               
                temp.Cells(Rows.Count, 1).End(xlUp).Offset(1).Resize(, 3) = Array(ws.Name, Cel.Address(0, 0), a)
            Next Cel
    Next
    temp.Range("A1").AutoFilter
End Sub
 
Upvote 0

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.
I put the code in that you included in post 30 and it worked great, what this code for?
 
Upvote 0
I just worked it out. Do I need it as it seems to work fine without it?
 
Upvote 0
I fixed the code in post#30 to work with the "bad" inconsistent format in Req# column

Some of your data was not consistent and that was why you had the problem with the code only working for some values
It is better practice if the format of values within one column is consistent - otherwise it may trip you up again in the future

It is your decision whether you want to change the values to make them consistent
- the code in post#31 is a tool to help you with that task

To fix the problem - manually select all 12 sheets together, select column C and format as text, then ungroup the sheets
 
Upvote 0
Sorry about that.

I have multiple allocation sheets, do I need to put it in a standard module of each allocation sheet and run it?
 
Upvote 0
So I think I can read the code and it looks like it updates column C to the text format, is that correct?
 
Upvote 0
So I think I can read the code and it looks like it updates column C to the text format, is that correct?
Yes, updates column "C"
AND
it goes in a standard MODULE, not in each sheet, as it has an array that modifies each sheet from that module
 
Upvote 0
Do you mean the code in post 31 goes in a standard module?
 
Upvote 0

Forum statistics

Threads
1,214,979
Messages
6,122,559
Members
449,089
Latest member
Motoracer88

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