Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Les Les is offline
external usenet poster
 
Posts: 240
Default Help with VBA loop, lookup and calculate problem

Hi all, i have the following scenario that i need to automate,

1. 2 sheets in one workbook(Report.xls), "Summary" & "LC PARTS"
2. Sheet "Summary" Column "C" has either 4 numbers or a 3 letter code,
starting from row 20 down.
3. Sheet "LC PARTS" has the Code in column "H".
4. Sheet "LC PARTS" has the Number in column "B".
5. Sheet "LC PARTS" has a number in column "N".

What i want to do is loop down column "C" in sheet "summary" & find the
first code/number and then look for the same value in sheet "LC Parts" column
"H"(code) and column "B"(Number) if it has found a number and then count the
number of blank cells in colummn "N". This total must then be place in the
same row on sheet "Summary" in column "J". It must loop down to the last
code/number on the sheet "Summary" as more can be added over time.

Thank you very much in advance for any help.

Les
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Help with VBA loop, lookup and calculate problem

what exactlly do you mean by "Number of blank cells in column N". Do you
mean the number of spaces in the cell? wouldn't the number of blank cells in
column N always be a constant?

"Les" wrote:

Hi all, i have the following scenario that i need to automate,

1. 2 sheets in one workbook(Report.xls), "Summary" & "LC PARTS"
2. Sheet "Summary" Column "C" has either 4 numbers or a 3 letter code,
starting from row 20 down.
3. Sheet "LC PARTS" has the Code in column "H".
4. Sheet "LC PARTS" has the Number in column "B".
5. Sheet "LC PARTS" has a number in column "N".

What i want to do is loop down column "C" in sheet "summary" & find the
first code/number and then look for the same value in sheet "LC Parts" column
"H"(code) and column "B"(Number) if it has found a number and then count the
number of blank cells in colummn "N". This total must then be place in the
same row on sheet "Summary" in column "J". It must loop down to the last
code/number on the sheet "Summary" as more can be added over time.

Thank you very much in advance for any help.

Les

  #3   Report Post  
Posted to microsoft.public.excel.programming
Les Les is offline
external usenet poster
 
Posts: 240
Default Help with VBA loop, lookup and calculate problem

Hi Noel, i mean the number of empty cells, as these are parts without an
order number which would be in column "N"

Summary Sheet:

"B" "C"
Bonnet Hood metal-Laepple 4161
Bumper (Front)-Venture 5111
Bumper (Rear)-Venture 5112
Centre Console-D&B CCL
Front End Module-Faurecia FRT
IMC-SAS IMC
Rear Axle Assembly-LMSA ACH

"LC SHEET":

A B C D F G
H N
4047116 3241 LC 4 SUCTION LINE 01 ACH
4047117 3241 LC 4 SUCTION LINE E9X AFS 01 ACH
4051502 3332 LC V DRIVE FLANGE HUB HIGH 01 ACH 2890210

Hope this helps.



--
Les


"Joel" wrote:

what exactlly do you mean by "Number of blank cells in column N". Do you
mean the number of spaces in the cell? wouldn't the number of blank cells in
column N always be a constant?

"Les" wrote:

Hi all, i have the following scenario that i need to automate,

1. 2 sheets in one workbook(Report.xls), "Summary" & "LC PARTS"
2. Sheet "Summary" Column "C" has either 4 numbers or a 3 letter code,
starting from row 20 down.
3. Sheet "LC PARTS" has the Code in column "H".
4. Sheet "LC PARTS" has the Number in column "B".
5. Sheet "LC PARTS" has a number in column "N".

What i want to do is loop down column "C" in sheet "summary" & find the
first code/number and then look for the same value in sheet "LC Parts" column
"H"(code) and column "B"(Number) if it has found a number and then count the
number of blank cells in colummn "N". This total must then be place in the
same row on sheet "Summary" in column "J". It must loop down to the last
code/number on the sheet "Summary" as more can be added over time.

Thank you very much in advance for any help.

Les

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Help with VBA loop, lookup and calculate problem

I did exactly what you requested. I think your instruction are missing some
requirements

Sub test()

With Sheets("LC PARTS")
LastRowParts = .Cells(Rows.Count, "C").End(xlUp).Row
NumberBlanks = 0
For RowCount = 1 To LastRowParts
If IsEmpty(.Cells(Rows.Count, "N")) Then
NumberBlanks = NumberBlanks + 1
End If
Next RowCount
End With

With Sheets("Summary")
LastRowSummary = .Cells(Rows.Count, "C").End(xlUp).Row
For RowCount = 20 To LastRowSummary
PartID = .Range("C" & RowCount)
If IsNumeric(PartID) Then
.Range("J" & RowCount) = NumberBlanks
With Sheets("LC PARTS")
Set c = Columns("B:B").Find(what:=PartID, _
LookIn:=xlValues)
If Not c Is Nothing Then
'enter more code here
End If
End With
Else
With Sheets("LC PARTS")
Set c = Columns("H:H").Find(what:=PartID, _
LookIn:=xlValues)
If Not c Is Nothing Then
'enter more code here
End If
End With
End If
Next RowCount

End With

End Sub


"Les" wrote:

Hi Noel, i mean the number of empty cells, as these are parts without an
order number which would be in column "N"

Summary Sheet:

"B" "C"
Bonnet Hood metal-Laepple 4161
Bumper (Front)-Venture 5111
Bumper (Rear)-Venture 5112
Centre Console-D&B CCL
Front End Module-Faurecia FRT
IMC-SAS IMC
Rear Axle Assembly-LMSA ACH

"LC SHEET":

A B C D F G
H N
4047116 3241 LC 4 SUCTION LINE 01 ACH
4047117 3241 LC 4 SUCTION LINE E9X AFS 01 ACH
4051502 3332 LC V DRIVE FLANGE HUB HIGH 01 ACH 2890210

Hope this helps.



--
Les


"Joel" wrote:

what exactlly do you mean by "Number of blank cells in column N". Do you
mean the number of spaces in the cell? wouldn't the number of blank cells in
column N always be a constant?

"Les" wrote:

Hi all, i have the following scenario that i need to automate,

1. 2 sheets in one workbook(Report.xls), "Summary" & "LC PARTS"
2. Sheet "Summary" Column "C" has either 4 numbers or a 3 letter code,
starting from row 20 down.
3. Sheet "LC PARTS" has the Code in column "H".
4. Sheet "LC PARTS" has the Number in column "B".
5. Sheet "LC PARTS" has a number in column "N".

What i want to do is loop down column "C" in sheet "summary" & find the
first code/number and then look for the same value in sheet "LC Parts" column
"H"(code) and column "B"(Number) if it has found a number and then count the
number of blank cells in colummn "N". This total must then be place in the
same row on sheet "Summary" in column "J". It must loop down to the last
code/number on the sheet "Summary" as more can be added over time.

Thank you very much in advance for any help.

Les

  #5   Report Post  
Posted to microsoft.public.excel.programming
Les Les is offline
external usenet poster
 
Posts: 240
Default Help with VBA loop, lookup and calculate problem

Hi Joel, I have to first get the value in sheet "Summary" column "C", either
a number or a 3 letter code e.g. 5141 or "SIT"

With this value found, if it is a number then i must look up in the sheet
"LC PARTS", column "B" for numbers and Column "H" for code, then count the
empty cells in column "N" .


--
Les


"Joel" wrote:

I did exactly what you requested. I think your instruction are missing some
requirements

Sub test()

With Sheets("LC PARTS")
LastRowParts = .Cells(Rows.Count, "C").End(xlUp).Row
NumberBlanks = 0
For RowCount = 1 To LastRowParts
If IsEmpty(.Cells(Rows.Count, "N")) Then
NumberBlanks = NumberBlanks + 1
End If
Next RowCount
End With

With Sheets("Summary")
LastRowSummary = .Cells(Rows.Count, "C").End(xlUp).Row
For RowCount = 20 To LastRowSummary
PartID = .Range("C" & RowCount)
If IsNumeric(PartID) Then
.Range("J" & RowCount) = NumberBlanks
With Sheets("LC PARTS")
Set c = Columns("B:B").Find(what:=PartID, _
LookIn:=xlValues)
If Not c Is Nothing Then
'enter more code here
End If
End With
Else
With Sheets("LC PARTS")
Set c = Columns("H:H").Find(what:=PartID, _
LookIn:=xlValues)
If Not c Is Nothing Then
'enter more code here
End If
End With
End If
Next RowCount

End With

End Sub


"Les" wrote:

Hi Noel, i mean the number of empty cells, as these are parts without an
order number which would be in column "N"

Summary Sheet:

"B" "C"
Bonnet Hood metal-Laepple 4161
Bumper (Front)-Venture 5111
Bumper (Rear)-Venture 5112
Centre Console-D&B CCL
Front End Module-Faurecia FRT
IMC-SAS IMC
Rear Axle Assembly-LMSA ACH

"LC SHEET":

A B C D F G
H N
4047116 3241 LC 4 SUCTION LINE 01 ACH
4047117 3241 LC 4 SUCTION LINE E9X AFS 01 ACH
4051502 3332 LC V DRIVE FLANGE HUB HIGH 01 ACH 2890210

Hope this helps.



--
Les


"Joel" wrote:

what exactlly do you mean by "Number of blank cells in column N". Do you
mean the number of spaces in the cell? wouldn't the number of blank cells in
column N always be a constant?

"Les" wrote:

Hi all, i have the following scenario that i need to automate,

1. 2 sheets in one workbook(Report.xls), "Summary" & "LC PARTS"
2. Sheet "Summary" Column "C" has either 4 numbers or a 3 letter code,
starting from row 20 down.
3. Sheet "LC PARTS" has the Code in column "H".
4. Sheet "LC PARTS" has the Number in column "B".
5. Sheet "LC PARTS" has a number in column "N".

What i want to do is loop down column "C" in sheet "summary" & find the
first code/number and then look for the same value in sheet "LC Parts" column
"H"(code) and column "B"(Number) if it has found a number and then count the
number of blank cells in colummn "N". This total must then be place in the
same row on sheet "Summary" in column "J". It must loop down to the last
code/number on the sheet "Summary" as more can be added over time.

Thank you very much in advance for any help.

Les



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Help with VBA loop, lookup and calculate problem

That is what the code does. what is the purpose of the lookup?????

"Les" wrote:

Hi Joel, I have to first get the value in sheet "Summary" column "C", either
a number or a 3 letter code e.g. 5141 or "SIT"

With this value found, if it is a number then i must look up in the sheet
"LC PARTS", column "B" for numbers and Column "H" for code, then count the
empty cells in column "N" .


--
Les


"Joel" wrote:

I did exactly what you requested. I think your instruction are missing some
requirements

Sub test()

With Sheets("LC PARTS")
LastRowParts = .Cells(Rows.Count, "C").End(xlUp).Row
NumberBlanks = 0
For RowCount = 1 To LastRowParts
If IsEmpty(.Cells(Rows.Count, "N")) Then
NumberBlanks = NumberBlanks + 1
End If
Next RowCount
End With

With Sheets("Summary")
LastRowSummary = .Cells(Rows.Count, "C").End(xlUp).Row
For RowCount = 20 To LastRowSummary
PartID = .Range("C" & RowCount)
If IsNumeric(PartID) Then
.Range("J" & RowCount) = NumberBlanks
With Sheets("LC PARTS")
Set c = Columns("B:B").Find(what:=PartID, _
LookIn:=xlValues)
If Not c Is Nothing Then
'enter more code here
End If
End With
Else
With Sheets("LC PARTS")
Set c = Columns("H:H").Find(what:=PartID, _
LookIn:=xlValues)
If Not c Is Nothing Then
'enter more code here
End If
End With
End If
Next RowCount

End With

End Sub


"Les" wrote:

Hi Noel, i mean the number of empty cells, as these are parts without an
order number which would be in column "N"

Summary Sheet:

"B" "C"
Bonnet Hood metal-Laepple 4161
Bumper (Front)-Venture 5111
Bumper (Rear)-Venture 5112
Centre Console-D&B CCL
Front End Module-Faurecia FRT
IMC-SAS IMC
Rear Axle Assembly-LMSA ACH

"LC SHEET":

A B C D F G
H N
4047116 3241 LC 4 SUCTION LINE 01 ACH
4047117 3241 LC 4 SUCTION LINE E9X AFS 01 ACH
4051502 3332 LC V DRIVE FLANGE HUB HIGH 01 ACH 2890210

Hope this helps.



--
Les


"Joel" wrote:

what exactlly do you mean by "Number of blank cells in column N". Do you
mean the number of spaces in the cell? wouldn't the number of blank cells in
column N always be a constant?

"Les" wrote:

Hi all, i have the following scenario that i need to automate,

1. 2 sheets in one workbook(Report.xls), "Summary" & "LC PARTS"
2. Sheet "Summary" Column "C" has either 4 numbers or a 3 letter code,
starting from row 20 down.
3. Sheet "LC PARTS" has the Code in column "H".
4. Sheet "LC PARTS" has the Number in column "B".
5. Sheet "LC PARTS" has a number in column "N".

What i want to do is loop down column "C" in sheet "summary" & find the
first code/number and then look for the same value in sheet "LC Parts" column
"H"(code) and column "B"(Number) if it has found a number and then count the
number of blank cells in colummn "N". This total must then be place in the
same row on sheet "Summary" in column "J". It must loop down to the last
code/number on the sheet "Summary" as more can be added over time.

Thank you very much in advance for any help.

Les

  #7   Report Post  
Posted to microsoft.public.excel.programming
Les Les is offline
external usenet poster
 
Posts: 240
Default Help with VBA loop, lookup and calculate problem

The lookup is so that it knows the number or code that i require the result
for.
e.g. for the code "SIT" i have 500 parts and need to see how many have
purchase orders. Therefore if i count the empty cells in "N" it will either
give me a zero result if all prchase orders are ther or it will tell me there
are 100 empty cells which will tell me that i am missing a 100 purchase
orders.
--
Les


"Joel" wrote:

That is what the code does. what is the purpose of the lookup?????

"Les" wrote:

Hi Joel, I have to first get the value in sheet "Summary" column "C", either
a number or a 3 letter code e.g. 5141 or "SIT"

With this value found, if it is a number then i must look up in the sheet
"LC PARTS", column "B" for numbers and Column "H" for code, then count the
empty cells in column "N" .


--
Les


"Joel" wrote:

I did exactly what you requested. I think your instruction are missing some
requirements

Sub test()

With Sheets("LC PARTS")
LastRowParts = .Cells(Rows.Count, "C").End(xlUp).Row
NumberBlanks = 0
For RowCount = 1 To LastRowParts
If IsEmpty(.Cells(Rows.Count, "N")) Then
NumberBlanks = NumberBlanks + 1
End If
Next RowCount
End With

With Sheets("Summary")
LastRowSummary = .Cells(Rows.Count, "C").End(xlUp).Row
For RowCount = 20 To LastRowSummary
PartID = .Range("C" & RowCount)
If IsNumeric(PartID) Then
.Range("J" & RowCount) = NumberBlanks
With Sheets("LC PARTS")
Set c = Columns("B:B").Find(what:=PartID, _
LookIn:=xlValues)
If Not c Is Nothing Then
'enter more code here
End If
End With
Else
With Sheets("LC PARTS")
Set c = Columns("H:H").Find(what:=PartID, _
LookIn:=xlValues)
If Not c Is Nothing Then
'enter more code here
End If
End With
End If
Next RowCount

End With

End Sub


"Les" wrote:

Hi Noel, i mean the number of empty cells, as these are parts without an
order number which would be in column "N"

Summary Sheet:

"B" "C"
Bonnet Hood metal-Laepple 4161
Bumper (Front)-Venture 5111
Bumper (Rear)-Venture 5112
Centre Console-D&B CCL
Front End Module-Faurecia FRT
IMC-SAS IMC
Rear Axle Assembly-LMSA ACH

"LC SHEET":

A B C D F G
H N
4047116 3241 LC 4 SUCTION LINE 01 ACH
4047117 3241 LC 4 SUCTION LINE E9X AFS 01 ACH
4051502 3332 LC V DRIVE FLANGE HUB HIGH 01 ACH 2890210

Hope this helps.



--
Les


"Joel" wrote:

what exactlly do you mean by "Number of blank cells in column N". Do you
mean the number of spaces in the cell? wouldn't the number of blank cells in
column N always be a constant?

"Les" wrote:

Hi all, i have the following scenario that i need to automate,

1. 2 sheets in one workbook(Report.xls), "Summary" & "LC PARTS"
2. Sheet "Summary" Column "C" has either 4 numbers or a 3 letter code,
starting from row 20 down.
3. Sheet "LC PARTS" has the Code in column "H".
4. Sheet "LC PARTS" has the Number in column "B".
5. Sheet "LC PARTS" has a number in column "N".

What i want to do is loop down column "C" in sheet "summary" & find the
first code/number and then look for the same value in sheet "LC Parts" column
"H"(code) and column "B"(Number) if it has found a number and then count the
number of blank cells in colummn "N". This total must then be place in the
same row on sheet "Summary" in column "J". It must loop down to the last
code/number on the sheet "Summary" as more can be added over time.

Thank you very much in advance for any help.

Les

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Help with VBA loop, lookup and calculate problem

try this code

Sub test()

With Sheets("LC PARTS")
LastRowParts = .Cells(Rows.Count, "C").End(xlUp).Row
End With

With Sheets("Summary")
LastRowSummary = .Cells(Rows.Count, "C").End(xlUp).Row
For SumRowCount = 20 To LastRowSummary
PartID = .Range("C" & SumRowCount)
If IsNumeric(PartID) Then
With Sheets("LC PARTS")
NumberBlanks = 0
For PartRowCount = 1 To LastRowParts
If PartID = .Range("B" & PartRowCount) Then
If IsEmpty(.Cells(PartRowCount, "N")) Then
NumberBlanks = NumberBlanks + 1
End If
End If
Next PartRowCount
End With
Else
With Sheets("LC PARTS")
NumberBlanks = 0
For PartRowCount = 1 To LastRowParts
If PartID = .Range("H" & PartRowCount) Then
If IsEmpty(.Cells(PartRowCount, "N")) Then
NumberBlanks = NumberBlanks + 1
End If
End If
Next PartRowCount
End With
End If
.Range("J" & SumRowCount) = NumberBlanks

Next SumRowCount

End With

End Sub

"Les" wrote:

The lookup is so that it knows the number or code that i require the result
for.
e.g. for the code "SIT" i have 500 parts and need to see how many have
purchase orders. Therefore if i count the empty cells in "N" it will either
give me a zero result if all prchase orders are ther or it will tell me there
are 100 empty cells which will tell me that i am missing a 100 purchase
orders.
--
Les


"Joel" wrote:

That is what the code does. what is the purpose of the lookup?????

"Les" wrote:

Hi Joel, I have to first get the value in sheet "Summary" column "C", either
a number or a 3 letter code e.g. 5141 or "SIT"

With this value found, if it is a number then i must look up in the sheet
"LC PARTS", column "B" for numbers and Column "H" for code, then count the
empty cells in column "N" .


--
Les


"Joel" wrote:

I did exactly what you requested. I think your instruction are missing some
requirements

Sub test()

With Sheets("LC PARTS")
LastRowParts = .Cells(Rows.Count, "C").End(xlUp).Row
NumberBlanks = 0
For RowCount = 1 To LastRowParts
If IsEmpty(.Cells(Rows.Count, "N")) Then
NumberBlanks = NumberBlanks + 1
End If
Next RowCount
End With

With Sheets("Summary")
LastRowSummary = .Cells(Rows.Count, "C").End(xlUp).Row
For RowCount = 20 To LastRowSummary
PartID = .Range("C" & RowCount)
If IsNumeric(PartID) Then
.Range("J" & RowCount) = NumberBlanks
With Sheets("LC PARTS")
Set c = Columns("B:B").Find(what:=PartID, _
LookIn:=xlValues)
If Not c Is Nothing Then
'enter more code here
End If
End With
Else
With Sheets("LC PARTS")
Set c = Columns("H:H").Find(what:=PartID, _
LookIn:=xlValues)
If Not c Is Nothing Then
'enter more code here
End If
End With
End If
Next RowCount

End With

End Sub


"Les" wrote:

Hi Noel, i mean the number of empty cells, as these are parts without an
order number which would be in column "N"

Summary Sheet:

"B" "C"
Bonnet Hood metal-Laepple 4161
Bumper (Front)-Venture 5111
Bumper (Rear)-Venture 5112
Centre Console-D&B CCL
Front End Module-Faurecia FRT
IMC-SAS IMC
Rear Axle Assembly-LMSA ACH

"LC SHEET":

A B C D F G
H N
4047116 3241 LC 4 SUCTION LINE 01 ACH
4047117 3241 LC 4 SUCTION LINE E9X AFS 01 ACH
4051502 3332 LC V DRIVE FLANGE HUB HIGH 01 ACH 2890210

Hope this helps.



--
Les


"Joel" wrote:

what exactlly do you mean by "Number of blank cells in column N". Do you
mean the number of spaces in the cell? wouldn't the number of blank cells in
column N always be a constant?

"Les" wrote:

Hi all, i have the following scenario that i need to automate,

1. 2 sheets in one workbook(Report.xls), "Summary" & "LC PARTS"
2. Sheet "Summary" Column "C" has either 4 numbers or a 3 letter code,
starting from row 20 down.
3. Sheet "LC PARTS" has the Code in column "H".
4. Sheet "LC PARTS" has the Number in column "B".
5. Sheet "LC PARTS" has a number in column "N".

What i want to do is loop down column "C" in sheet "summary" & find the
first code/number and then look for the same value in sheet "LC Parts" column
"H"(code) and column "B"(Number) if it has found a number and then count the
number of blank cells in colummn "N". This total must then be place in the
same row on sheet "Summary" in column "J". It must loop down to the last
code/number on the sheet "Summary" as more can be added over time.

Thank you very much in advance for any help.

Les

  #9   Report Post  
Posted to microsoft.public.excel.programming
Les Les is offline
external usenet poster
 
Posts: 240
Default Help with VBA loop, lookup and calculate problem

Hi Joel, thanks so much, it would appear to be doing it, but does not see the
empty cells for some reason so always returns a ZERO in column "J" ?
--
Les


"Joel" wrote:

try this code

Sub test()

With Sheets("LC PARTS")
LastRowParts = .Cells(Rows.Count, "C").End(xlUp).Row
End With

With Sheets("Summary")
LastRowSummary = .Cells(Rows.Count, "C").End(xlUp).Row
For SumRowCount = 20 To LastRowSummary
PartID = .Range("C" & SumRowCount)
If IsNumeric(PartID) Then
With Sheets("LC PARTS")
NumberBlanks = 0
For PartRowCount = 1 To LastRowParts
If PartID = .Range("B" & PartRowCount) Then
If IsEmpty(.Cells(PartRowCount, "N")) Then
NumberBlanks = NumberBlanks + 1
End If
End If
Next PartRowCount
End With
Else
With Sheets("LC PARTS")
NumberBlanks = 0
For PartRowCount = 1 To LastRowParts
If PartID = .Range("H" & PartRowCount) Then
If IsEmpty(.Cells(PartRowCount, "N")) Then
NumberBlanks = NumberBlanks + 1
End If
End If
Next PartRowCount
End With
End If
.Range("J" & SumRowCount) = NumberBlanks

Next SumRowCount

End With

End Sub

"Les" wrote:

The lookup is so that it knows the number or code that i require the result
for.
e.g. for the code "SIT" i have 500 parts and need to see how many have
purchase orders. Therefore if i count the empty cells in "N" it will either
give me a zero result if all prchase orders are ther or it will tell me there
are 100 empty cells which will tell me that i am missing a 100 purchase
orders.
--
Les


"Joel" wrote:

That is what the code does. what is the purpose of the lookup?????

"Les" wrote:

Hi Joel, I have to first get the value in sheet "Summary" column "C", either
a number or a 3 letter code e.g. 5141 or "SIT"

With this value found, if it is a number then i must look up in the sheet
"LC PARTS", column "B" for numbers and Column "H" for code, then count the
empty cells in column "N" .


--
Les


"Joel" wrote:

I did exactly what you requested. I think your instruction are missing some
requirements

Sub test()

With Sheets("LC PARTS")
LastRowParts = .Cells(Rows.Count, "C").End(xlUp).Row
NumberBlanks = 0
For RowCount = 1 To LastRowParts
If IsEmpty(.Cells(Rows.Count, "N")) Then
NumberBlanks = NumberBlanks + 1
End If
Next RowCount
End With

With Sheets("Summary")
LastRowSummary = .Cells(Rows.Count, "C").End(xlUp).Row
For RowCount = 20 To LastRowSummary
PartID = .Range("C" & RowCount)
If IsNumeric(PartID) Then
.Range("J" & RowCount) = NumberBlanks
With Sheets("LC PARTS")
Set c = Columns("B:B").Find(what:=PartID, _
LookIn:=xlValues)
If Not c Is Nothing Then
'enter more code here
End If
End With
Else
With Sheets("LC PARTS")
Set c = Columns("H:H").Find(what:=PartID, _
LookIn:=xlValues)
If Not c Is Nothing Then
'enter more code here
End If
End With
End If
Next RowCount

End With

End Sub


"Les" wrote:

Hi Noel, i mean the number of empty cells, as these are parts without an
order number which would be in column "N"

Summary Sheet:

"B" "C"
Bonnet Hood metal-Laepple 4161
Bumper (Front)-Venture 5111
Bumper (Rear)-Venture 5112
Centre Console-D&B CCL
Front End Module-Faurecia FRT
IMC-SAS IMC
Rear Axle Assembly-LMSA ACH

"LC SHEET":

A B C D F G
H N
4047116 3241 LC 4 SUCTION LINE 01 ACH
4047117 3241 LC 4 SUCTION LINE E9X AFS 01 ACH
4051502 3332 LC V DRIVE FLANGE HUB HIGH 01 ACH 2890210

Hope this helps.



--
Les


"Joel" wrote:

what exactlly do you mean by "Number of blank cells in column N". Do you
mean the number of spaces in the cell? wouldn't the number of blank cells in
column N always be a constant?

"Les" wrote:

Hi all, i have the following scenario that i need to automate,

1. 2 sheets in one workbook(Report.xls), "Summary" & "LC PARTS"
2. Sheet "Summary" Column "C" has either 4 numbers or a 3 letter code,
starting from row 20 down.
3. Sheet "LC PARTS" has the Code in column "H".
4. Sheet "LC PARTS" has the Number in column "B".
5. Sheet "LC PARTS" has a number in column "N".

What i want to do is loop down column "C" in sheet "summary" & find the
first code/number and then look for the same value in sheet "LC Parts" column
"H"(code) and column "B"(Number) if it has found a number and then count the
number of blank cells in colummn "N". This total must then be place in the
same row on sheet "Summary" in column "J". It must loop down to the last
code/number on the sheet "Summary" as more can be added over time.

Thank you very much in advance for any help.

Les

  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Help with VBA loop, lookup and calculate problem

Les: Can you put a break point on the two Isempty statements? let me know if
it is getting to neither, one, or both is empty.

click the line with Isempty and then press F9.

there are at least 3 differentt reasons for rereturning zero
1) Lastrow could be wrong
2) PartID may not be matching.
3) IsEmpty is not recognizing the empty cell.

Because one is a stgring and one is a number I think the solution would be
differentt for each

first case "number"
from
If IsEmpty(.Cells(PartRowCount, "N")) Then
to
If not numeric(.Cells(PartRowCount, "N")) Then

second case "text"
from
If IsEmpty(.Cells(PartRowCount, "N")) Then
to
If .Cells(PartRowCount, "N") < "" Then

"Les" wrote:

Hi Joel, thanks so much, it would appear to be doing it, but does not see the
empty cells for some reason so always returns a ZERO in column "J" ?
--
Les


"Joel" wrote:

try this code

Sub test()

With Sheets("LC PARTS")
LastRowParts = .Cells(Rows.Count, "C").End(xlUp).Row
End With

With Sheets("Summary")
LastRowSummary = .Cells(Rows.Count, "C").End(xlUp).Row
For SumRowCount = 20 To LastRowSummary
PartID = .Range("C" & SumRowCount)
If IsNumeric(PartID) Then
With Sheets("LC PARTS")
NumberBlanks = 0
For PartRowCount = 1 To LastRowParts
If PartID = .Range("B" & PartRowCount) Then
If IsEmpty(.Cells(PartRowCount, "N")) Then
NumberBlanks = NumberBlanks + 1
End If
End If
Next PartRowCount
End With
Else
With Sheets("LC PARTS")
NumberBlanks = 0
For PartRowCount = 1 To LastRowParts
If PartID = .Range("H" & PartRowCount) Then
If IsEmpty(.Cells(PartRowCount, "N")) Then
NumberBlanks = NumberBlanks + 1
End If
End If
Next PartRowCount
End With
End If
.Range("J" & SumRowCount) = NumberBlanks

Next SumRowCount

End With

End Sub

"Les" wrote:

The lookup is so that it knows the number or code that i require the result
for.
e.g. for the code "SIT" i have 500 parts and need to see how many have
purchase orders. Therefore if i count the empty cells in "N" it will either
give me a zero result if all prchase orders are ther or it will tell me there
are 100 empty cells which will tell me that i am missing a 100 purchase
orders.
--
Les


"Joel" wrote:

That is what the code does. what is the purpose of the lookup?????

"Les" wrote:

Hi Joel, I have to first get the value in sheet "Summary" column "C", either
a number or a 3 letter code e.g. 5141 or "SIT"

With this value found, if it is a number then i must look up in the sheet
"LC PARTS", column "B" for numbers and Column "H" for code, then count the
empty cells in column "N" .


--
Les


"Joel" wrote:

I did exactly what you requested. I think your instruction are missing some
requirements

Sub test()

With Sheets("LC PARTS")
LastRowParts = .Cells(Rows.Count, "C").End(xlUp).Row
NumberBlanks = 0
For RowCount = 1 To LastRowParts
If IsEmpty(.Cells(Rows.Count, "N")) Then
NumberBlanks = NumberBlanks + 1
End If
Next RowCount
End With

With Sheets("Summary")
LastRowSummary = .Cells(Rows.Count, "C").End(xlUp).Row
For RowCount = 20 To LastRowSummary
PartID = .Range("C" & RowCount)
If IsNumeric(PartID) Then
.Range("J" & RowCount) = NumberBlanks
With Sheets("LC PARTS")
Set c = Columns("B:B").Find(what:=PartID, _
LookIn:=xlValues)
If Not c Is Nothing Then
'enter more code here
End If
End With
Else
With Sheets("LC PARTS")
Set c = Columns("H:H").Find(what:=PartID, _
LookIn:=xlValues)
If Not c Is Nothing Then
'enter more code here
End If
End With
End If
Next RowCount

End With

End Sub


"Les" wrote:

Hi Noel, i mean the number of empty cells, as these are parts without an
order number which would be in column "N"

Summary Sheet:

"B" "C"
Bonnet Hood metal-Laepple 4161
Bumper (Front)-Venture 5111
Bumper (Rear)-Venture 5112
Centre Console-D&B CCL
Front End Module-Faurecia FRT
IMC-SAS IMC
Rear Axle Assembly-LMSA ACH

"LC SHEET":

A B C D F G
H N
4047116 3241 LC 4 SUCTION LINE 01 ACH
4047117 3241 LC 4 SUCTION LINE E9X AFS 01 ACH
4051502 3332 LC V DRIVE FLANGE HUB HIGH 01 ACH 2890210

Hope this helps.



--
Les


"Joel" wrote:

what exactlly do you mean by "Number of blank cells in column N". Do you
mean the number of spaces in the cell? wouldn't the number of blank cells in
column N always be a constant?

"Les" wrote:

Hi all, i have the following scenario that i need to automate,

1. 2 sheets in one workbook(Report.xls), "Summary" & "LC PARTS"
2. Sheet "Summary" Column "C" has either 4 numbers or a 3 letter code,
starting from row 20 down.
3. Sheet "LC PARTS" has the Code in column "H".
4. Sheet "LC PARTS" has the Number in column "B".
5. Sheet "LC PARTS" has a number in column "N".

What i want to do is loop down column "C" in sheet "summary" & find the
first code/number and then look for the same value in sheet "LC Parts" column
"H"(code) and column "B"(Number) if it has found a number and then count the
number of blank cells in colummn "N". This total must then be place in the
same row on sheet "Summary" in column "J". It must loop down to the last
code/number on the sheet "Summary" as more can be added over time.

Thank you very much in advance for any help.

Les



  #11   Report Post  
Posted to microsoft.public.excel.programming
Les Les is offline
external usenet poster
 
Posts: 240
Default Help with VBA loop, lookup and calculate problem

Hi Joel, there is no problem with the "Text" or code but the problem is with
the "Number" i jave played around with the formats and it seems to be working.

Have to go home now, 19:45 here in South Africa, will try in the morning
again. Thanks so much for your help.
--
Les


"Joel" wrote:

Les: Can you put a break point on the two Isempty statements? let me know if
it is getting to neither, one, or both is empty.

click the line with Isempty and then press F9.

there are at least 3 differentt reasons for rereturning zero
1) Lastrow could be wrong
2) PartID may not be matching.
3) IsEmpty is not recognizing the empty cell.

Because one is a stgring and one is a number I think the solution would be
differentt for each

first case "number"
from
If IsEmpty(.Cells(PartRowCount, "N")) Then
to
If not numeric(.Cells(PartRowCount, "N")) Then

second case "text"
from
If IsEmpty(.Cells(PartRowCount, "N")) Then
to
If .Cells(PartRowCount, "N") < "" Then

"Les" wrote:

Hi Joel, thanks so much, it would appear to be doing it, but does not see the
empty cells for some reason so always returns a ZERO in column "J" ?
--
Les


"Joel" wrote:

try this code

Sub test()

With Sheets("LC PARTS")
LastRowParts = .Cells(Rows.Count, "C").End(xlUp).Row
End With

With Sheets("Summary")
LastRowSummary = .Cells(Rows.Count, "C").End(xlUp).Row
For SumRowCount = 20 To LastRowSummary
PartID = .Range("C" & SumRowCount)
If IsNumeric(PartID) Then
With Sheets("LC PARTS")
NumberBlanks = 0
For PartRowCount = 1 To LastRowParts
If PartID = .Range("B" & PartRowCount) Then
If IsEmpty(.Cells(PartRowCount, "N")) Then
NumberBlanks = NumberBlanks + 1
End If
End If
Next PartRowCount
End With
Else
With Sheets("LC PARTS")
NumberBlanks = 0
For PartRowCount = 1 To LastRowParts
If PartID = .Range("H" & PartRowCount) Then
If IsEmpty(.Cells(PartRowCount, "N")) Then
NumberBlanks = NumberBlanks + 1
End If
End If
Next PartRowCount
End With
End If
.Range("J" & SumRowCount) = NumberBlanks

Next SumRowCount

End With

End Sub

"Les" wrote:

The lookup is so that it knows the number or code that i require the result
for.
e.g. for the code "SIT" i have 500 parts and need to see how many have
purchase orders. Therefore if i count the empty cells in "N" it will either
give me a zero result if all prchase orders are ther or it will tell me there
are 100 empty cells which will tell me that i am missing a 100 purchase
orders.
--
Les


"Joel" wrote:

That is what the code does. what is the purpose of the lookup?????

"Les" wrote:

Hi Joel, I have to first get the value in sheet "Summary" column "C", either
a number or a 3 letter code e.g. 5141 or "SIT"

With this value found, if it is a number then i must look up in the sheet
"LC PARTS", column "B" for numbers and Column "H" for code, then count the
empty cells in column "N" .


--
Les


"Joel" wrote:

I did exactly what you requested. I think your instruction are missing some
requirements

Sub test()

With Sheets("LC PARTS")
LastRowParts = .Cells(Rows.Count, "C").End(xlUp).Row
NumberBlanks = 0
For RowCount = 1 To LastRowParts
If IsEmpty(.Cells(Rows.Count, "N")) Then
NumberBlanks = NumberBlanks + 1
End If
Next RowCount
End With

With Sheets("Summary")
LastRowSummary = .Cells(Rows.Count, "C").End(xlUp).Row
For RowCount = 20 To LastRowSummary
PartID = .Range("C" & RowCount)
If IsNumeric(PartID) Then
.Range("J" & RowCount) = NumberBlanks
With Sheets("LC PARTS")
Set c = Columns("B:B").Find(what:=PartID, _
LookIn:=xlValues)
If Not c Is Nothing Then
'enter more code here
End If
End With
Else
With Sheets("LC PARTS")
Set c = Columns("H:H").Find(what:=PartID, _
LookIn:=xlValues)
If Not c Is Nothing Then
'enter more code here
End If
End With
End If
Next RowCount

End With

End Sub


"Les" wrote:

Hi Noel, i mean the number of empty cells, as these are parts without an
order number which would be in column "N"

Summary Sheet:

"B" "C"
Bonnet Hood metal-Laepple 4161
Bumper (Front)-Venture 5111
Bumper (Rear)-Venture 5112
Centre Console-D&B CCL
Front End Module-Faurecia FRT
IMC-SAS IMC
Rear Axle Assembly-LMSA ACH

"LC SHEET":

A B C D F G
H N
4047116 3241 LC 4 SUCTION LINE 01 ACH
4047117 3241 LC 4 SUCTION LINE E9X AFS 01 ACH
4051502 3332 LC V DRIVE FLANGE HUB HIGH 01 ACH 2890210

Hope this helps.



--
Les


"Joel" wrote:

what exactlly do you mean by "Number of blank cells in column N". Do you
mean the number of spaces in the cell? wouldn't the number of blank cells in
column N always be a constant?

"Les" wrote:

Hi all, i have the following scenario that i need to automate,

1. 2 sheets in one workbook(Report.xls), "Summary" & "LC PARTS"
2. Sheet "Summary" Column "C" has either 4 numbers or a 3 letter code,
starting from row 20 down.
3. Sheet "LC PARTS" has the Code in column "H".
4. Sheet "LC PARTS" has the Number in column "B".
5. Sheet "LC PARTS" has a number in column "N".

What i want to do is loop down column "C" in sheet "summary" & find the
first code/number and then look for the same value in sheet "LC Parts" column
"H"(code) and column "B"(Number) if it has found a number and then count the
number of blank cells in colummn "N". This total must then be place in the
same row on sheet "Summary" in column "J". It must loop down to the last
code/number on the sheet "Summary" as more can be added over time.

Thank you very much in advance for any help.

Les

  #12   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Help with VBA loop, lookup and calculate problem

This is the 1st time someone on the African Continent has said I provided
help. I only need somebody in Antartica to complete all 7.

"Les" wrote:

Hi Joel, there is no problem with the "Text" or code but the problem is with
the "Number" i jave played around with the formats and it seems to be working.

Have to go home now, 19:45 here in South Africa, will try in the morning
again. Thanks so much for your help.
--
Les


"Joel" wrote:

Les: Can you put a break point on the two Isempty statements? let me know if
it is getting to neither, one, or both is empty.

click the line with Isempty and then press F9.

there are at least 3 differentt reasons for rereturning zero
1) Lastrow could be wrong
2) PartID may not be matching.
3) IsEmpty is not recognizing the empty cell.

Because one is a stgring and one is a number I think the solution would be
differentt for each

first case "number"
from
If IsEmpty(.Cells(PartRowCount, "N")) Then
to
If not numeric(.Cells(PartRowCount, "N")) Then

second case "text"
from
If IsEmpty(.Cells(PartRowCount, "N")) Then
to
If .Cells(PartRowCount, "N") < "" Then

"Les" wrote:

Hi Joel, thanks so much, it would appear to be doing it, but does not see the
empty cells for some reason so always returns a ZERO in column "J" ?
--
Les


"Joel" wrote:

try this code

Sub test()

With Sheets("LC PARTS")
LastRowParts = .Cells(Rows.Count, "C").End(xlUp).Row
End With

With Sheets("Summary")
LastRowSummary = .Cells(Rows.Count, "C").End(xlUp).Row
For SumRowCount = 20 To LastRowSummary
PartID = .Range("C" & SumRowCount)
If IsNumeric(PartID) Then
With Sheets("LC PARTS")
NumberBlanks = 0
For PartRowCount = 1 To LastRowParts
If PartID = .Range("B" & PartRowCount) Then
If IsEmpty(.Cells(PartRowCount, "N")) Then
NumberBlanks = NumberBlanks + 1
End If
End If
Next PartRowCount
End With
Else
With Sheets("LC PARTS")
NumberBlanks = 0
For PartRowCount = 1 To LastRowParts
If PartID = .Range("H" & PartRowCount) Then
If IsEmpty(.Cells(PartRowCount, "N")) Then
NumberBlanks = NumberBlanks + 1
End If
End If
Next PartRowCount
End With
End If
.Range("J" & SumRowCount) = NumberBlanks

Next SumRowCount

End With

End Sub

"Les" wrote:

The lookup is so that it knows the number or code that i require the result
for.
e.g. for the code "SIT" i have 500 parts and need to see how many have
purchase orders. Therefore if i count the empty cells in "N" it will either
give me a zero result if all prchase orders are ther or it will tell me there
are 100 empty cells which will tell me that i am missing a 100 purchase
orders.
--
Les


"Joel" wrote:

That is what the code does. what is the purpose of the lookup?????

"Les" wrote:

Hi Joel, I have to first get the value in sheet "Summary" column "C", either
a number or a 3 letter code e.g. 5141 or "SIT"

With this value found, if it is a number then i must look up in the sheet
"LC PARTS", column "B" for numbers and Column "H" for code, then count the
empty cells in column "N" .


--
Les


"Joel" wrote:

I did exactly what you requested. I think your instruction are missing some
requirements

Sub test()

With Sheets("LC PARTS")
LastRowParts = .Cells(Rows.Count, "C").End(xlUp).Row
NumberBlanks = 0
For RowCount = 1 To LastRowParts
If IsEmpty(.Cells(Rows.Count, "N")) Then
NumberBlanks = NumberBlanks + 1
End If
Next RowCount
End With

With Sheets("Summary")
LastRowSummary = .Cells(Rows.Count, "C").End(xlUp).Row
For RowCount = 20 To LastRowSummary
PartID = .Range("C" & RowCount)
If IsNumeric(PartID) Then
.Range("J" & RowCount) = NumberBlanks
With Sheets("LC PARTS")
Set c = Columns("B:B").Find(what:=PartID, _
LookIn:=xlValues)
If Not c Is Nothing Then
'enter more code here
End If
End With
Else
With Sheets("LC PARTS")
Set c = Columns("H:H").Find(what:=PartID, _
LookIn:=xlValues)
If Not c Is Nothing Then
'enter more code here
End If
End With
End If
Next RowCount

End With

End Sub


"Les" wrote:

Hi Noel, i mean the number of empty cells, as these are parts without an
order number which would be in column "N"

Summary Sheet:

"B" "C"
Bonnet Hood metal-Laepple 4161
Bumper (Front)-Venture 5111
Bumper (Rear)-Venture 5112
Centre Console-D&B CCL
Front End Module-Faurecia FRT
IMC-SAS IMC
Rear Axle Assembly-LMSA ACH

"LC SHEET":

A B C D F G
H N
4047116 3241 LC 4 SUCTION LINE 01 ACH
4047117 3241 LC 4 SUCTION LINE E9X AFS 01 ACH
4051502 3332 LC V DRIVE FLANGE HUB HIGH 01 ACH 2890210

Hope this helps.



--
Les


"Joel" wrote:

what exactlly do you mean by "Number of blank cells in column N". Do you
mean the number of spaces in the cell? wouldn't the number of blank cells in
column N always be a constant?

"Les" wrote:

Hi all, i have the following scenario that i need to automate,

1. 2 sheets in one workbook(Report.xls), "Summary" & "LC PARTS"
2. Sheet "Summary" Column "C" has either 4 numbers or a 3 letter code,
starting from row 20 down.
3. Sheet "LC PARTS" has the Code in column "H".
4. Sheet "LC PARTS" has the Number in column "B".
5. Sheet "LC PARTS" has a number in column "N".

What i want to do is loop down column "C" in sheet "summary" & find the
first code/number and then look for the same value in sheet "LC Parts" column
"H"(code) and column "B"(Number) if it has found a number and then count the
number of blank cells in colummn "N". This total must then be place in the
same row on sheet "Summary" in column "J". It must loop down to the last
code/number on the sheet "Summary" as more can be added over time.

Thank you very much in advance for any help.

Les

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Auto-calculate after a cell is filled in - macro shouldn't be loop raphiel2063 Excel Programming 5 September 6th 07 04:30 PM
Lookup / Loop / Help Requested [email protected] Excel Programming 1 March 1st 07 08:24 PM
Loop & Calculate Paul Black Excel Programming 0 August 27th 06 06:36 PM
Problem adding charts using Do-Loop Until loop Chris Bromley[_2_] Excel Programming 2 May 23rd 05 01:31 PM
Loop expression to calculate return Jason Excel Programming 1 July 14th 04 01:27 AM


All times are GMT +1. The time now is 07:43 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"