#1   Report Post  
Posted to microsoft.public.excel.misc
Harry
 
Posts: n/a
Default question on macro

Hi,

I have a spreadsheet at hand that is an output from a lab computer. Until
now, I had to do some simple calculations with excel on this sheet. But in
future I want to do more. For this I need a simple (I think) solution for a
problem. But it seems I cannot find how to do that :-)

In essence it comes down to this:

-I have a workbook with two sheets.
-In sheet one is the output file (xls) from a laboratory machine. This
consists mainly of multiple colums with each a unique text header in the
top row. Each column has a variable number of cells depending on what
analysis is done by the lab machine. It can be 10 cells or 100 cells under
each header. In practice this means that sheet one can consist of anything
from 2 to 400 rows with all numbers possible in between.
-In sheet two I have a list in one column of all possible column headers
that could be found in sheet 1 (this is made up by an total output list from
the lab machine).
Note that not from every analysis, all header names are put in sheet one.
That depends on the analysis again.
So the total list on sheet two can be 200 names long while the output from
the
labmachine to sheet one could consist of e.g. only of these 20 headers with
a variable
number of cells under each header.
-I want a macro that takes every name from sheet two and checks if it is in
the current header row of sheet one. IF SO, I want the macro to select the
cells under that column header for as far the column is filled with values.
-With this selection made by the macro, I than want to perform another
action (maybe copying it to another section of the workbook or maybe give
the selected range a name - but that is something I have to look at later).

Anybody able to help?

Regards,
Harry



  #2   Report Post  
Posted to microsoft.public.excel.misc
mrice
 
Posts: n/a
Default question on macro


Harry

Looks like a relatively simple macro could help here.

It would be based around the use of the application.countif function.

If you go to my home page, you can send a copy to me so I could look at
it in more detail.

Martin

http://homepage.ntlworld.com/martin.rice1/


--
mrice
------------------------------------------------------------------------
mrice's Profile: http://www.excelforum.com/member.php...o&userid=10931
View this thread: http://www.excelforum.com/showthread...hreadid=531972

  #3   Report Post  
Posted to microsoft.public.excel.misc
JMB
 
Posts: n/a
Default question on macro

One way to find the range(s). It just gives a message box with the range
address -change when you decide what you want to do with it. Note I'm using
the codenames for the worksheets (check VBA help for more info). I'm
assuming your list is on Sheet2 Column A and the headers of the imported data
is on Shee1, Row1. Hope it helps.

Sub test()
Dim x As Range
Dim FoundCell As Range

With Sheet2
For Each x In .Range("A1", _
.Cells(.Rows.Count, 1).End(xlUp))
With Sheet1.Rows("1:1")
Set FoundCell = .Find(what:=x.Value, _
after:=.Cells(1, 1), LookIn:=xlValues, _
lookat:=xlWhole, searchorder:=xlByRows, _
searchdirection:=xlNext, MatchCase:=False, _
matchbyte:=False)
If Not FoundCell Is Nothing Then
With .Parent
MsgBox .Range(FoundCell, .Cells(.Rows.Count, _
FoundCell.Column).End(xlUp)).Address
End With
Else: MsgBox "Not Found"
End If
End With
Next x
End With

End Sub


"Harry" wrote:

Hi,

I have a spreadsheet at hand that is an output from a lab computer. Until
now, I had to do some simple calculations with excel on this sheet. But in
future I want to do more. For this I need a simple (I think) solution for a
problem. But it seems I cannot find how to do that :-)

In essence it comes down to this:

-I have a workbook with two sheets.
-In sheet one is the output file (xls) from a laboratory machine. This
consists mainly of multiple colums with each a unique text header in the
top row. Each column has a variable number of cells depending on what
analysis is done by the lab machine. It can be 10 cells or 100 cells under
each header. In practice this means that sheet one can consist of anything
from 2 to 400 rows with all numbers possible in between.
-In sheet two I have a list in one column of all possible column headers
that could be found in sheet 1 (this is made up by an total output list from
the lab machine).
Note that not from every analysis, all header names are put in sheet one.
That depends on the analysis again.
So the total list on sheet two can be 200 names long while the output from
the
labmachine to sheet one could consist of e.g. only of these 20 headers with
a variable
number of cells under each header.
-I want a macro that takes every name from sheet two and checks if it is in
the current header row of sheet one. IF SO, I want the macro to select the
cells under that column header for as far the column is filled with values.
-With this selection made by the macro, I than want to perform another
action (maybe copying it to another section of the workbook or maybe give
the selected range a name - but that is something I have to look at later).

Anybody able to help?

Regards,
Harry




  #4   Report Post  
Posted to microsoft.public.excel.misc
Harry
 
Posts: n/a
Default question on macro

JMB,

Thx alot for the thinking! Great!
I have to study this macro of yours. And I will try to adopt in in my
workbook. And I will try to let you know if it worked.

Regards
Harry

"JMB" schreef in bericht
...
One way to find the range(s). It just gives a message box with the range
address -change when you decide what you want to do with it. Note I'm
using
the codenames for the worksheets (check VBA help for more info). I'm
assuming your list is on Sheet2 Column A and the headers of the imported
data
is on Shee1, Row1. Hope it helps.

Sub test()
Dim x As Range
Dim FoundCell As Range

With Sheet2
For Each x In .Range("A1", _
.Cells(.Rows.Count, 1).End(xlUp))
With Sheet1.Rows("1:1")
Set FoundCell = .Find(what:=x.Value, _
after:=.Cells(1, 1), LookIn:=xlValues, _
lookat:=xlWhole, searchorder:=xlByRows, _
searchdirection:=xlNext, MatchCase:=False, _
matchbyte:=False)
If Not FoundCell Is Nothing Then
With .Parent
MsgBox .Range(FoundCell, .Cells(.Rows.Count, _
FoundCell.Column).End(xlUp)).Address
End With
Else: MsgBox "Not Found"
End If
End With
Next x
End With

End Sub


"Harry" wrote:

Hi,

I have a spreadsheet at hand that is an output from a lab computer. Until
now, I had to do some simple calculations with excel on this sheet. But
in
future I want to do more. For this I need a simple (I think) solution for
a
problem. But it seems I cannot find how to do that :-)

In essence it comes down to this:

-I have a workbook with two sheets.
-In sheet one is the output file (xls) from a laboratory machine. This
consists mainly of multiple colums with each a unique text header in the
top row. Each column has a variable number of cells depending on what
analysis is done by the lab machine. It can be 10 cells or 100 cells
under
each header. In practice this means that sheet one can consist of
anything
from 2 to 400 rows with all numbers possible in between.
-In sheet two I have a list in one column of all possible column headers
that could be found in sheet 1 (this is made up by an total output list
from
the lab machine).
Note that not from every analysis, all header names are put in sheet one.
That depends on the analysis again.
So the total list on sheet two can be 200 names long while the output
from
the
labmachine to sheet one could consist of e.g. only of these 20 headers
with
a variable
number of cells under each header.
-I want a macro that takes every name from sheet two and checks if it is
in
the current header row of sheet one. IF SO, I want the macro to select
the
cells under that column header for as far the column is filled with
values.
-With this selection made by the macro, I than want to perform another
action (maybe copying it to another section of the workbook or maybe give
the selected range a name - but that is something I have to look at
later).

Anybody able to help?

Regards,
Harry






  #5   Report Post  
Posted to microsoft.public.excel.misc
Harry
 
Posts: n/a
Default question on macro

JMB,

I managed to get this macro working ones. It was giving me all ranges in a
message box.
But after that first time I keep getting an error message when it reaches
"For Each x In .Range".
The error says something like "Error 424 during execution, object needed"

The complete test of the macro in my actual workbook reads :

Sub test()
Dim x As Range
Dim FoundCell As Range

With Blad2
For Each x In .Range("A1", .Cells(.Rows.Count, 1).End(xlUp))
With Blad1.Rows("1:1")
Set FoundCell = .Find(what:=x.Value, after:=.Cells(1, 1),
LookIn:=xlValues, lookat:=xlWhole, searchorder:=xlByRows,
searchdirection:=xlNext, MatchCase:=False, matchbyte:=False)
If Not FoundCell Is Nothing Then
With .Parent
MsgBox .Range(FoundCell, .Cells(.Rows.Count,
FoundCell.Column).End(xlUp)).Address
End With
Else: MsgBox "Not Found"
End If
End With
Next x
End With

End Sub

The only thing altered was that in my Dutch excel, a sheet is called "Blad".
Any idea why it worked once and not again????

Harry



"JMB" schreef in bericht
...
One way to find the range(s). It just gives a message box with the range
address -change when you decide what you want to do with it. Note I'm
using
the codenames for the worksheets (check VBA help for more info). I'm
assuming your list is on Sheet2 Column A and the headers of the imported
data
is on Shee1, Row1. Hope it helps.

Sub test()
Dim x As Range
Dim FoundCell As Range

With Sheet2
For Each x In .Range("A1", _
.Cells(.Rows.Count, 1).End(xlUp))
With Sheet1.Rows("1:1")
Set FoundCell = .Find(what:=x.Value, _
after:=.Cells(1, 1), LookIn:=xlValues, _
lookat:=xlWhole, searchorder:=xlByRows, _
searchdirection:=xlNext, MatchCase:=False, _
matchbyte:=False)
If Not FoundCell Is Nothing Then
With .Parent
MsgBox .Range(FoundCell, .Cells(.Rows.Count, _
FoundCell.Column).End(xlUp)).Address
End With
Else: MsgBox "Not Found"
End If
End With
Next x
End With

End Sub


"Harry" wrote:

Hi,

I have a spreadsheet at hand that is an output from a lab computer. Until
now, I had to do some simple calculations with excel on this sheet. But
in
future I want to do more. For this I need a simple (I think) solution for
a
problem. But it seems I cannot find how to do that :-)

In essence it comes down to this:

-I have a workbook with two sheets.
-In sheet one is the output file (xls) from a laboratory machine. This
consists mainly of multiple colums with each a unique text header in the
top row. Each column has a variable number of cells depending on what
analysis is done by the lab machine. It can be 10 cells or 100 cells
under
each header. In practice this means that sheet one can consist of
anything
from 2 to 400 rows with all numbers possible in between.
-In sheet two I have a list in one column of all possible column headers
that could be found in sheet 1 (this is made up by an total output list
from
the lab machine).
Note that not from every analysis, all header names are put in sheet one.
That depends on the analysis again.
So the total list on sheet two can be 200 names long while the output
from
the
labmachine to sheet one could consist of e.g. only of these 20 headers
with
a variable
number of cells under each header.
-I want a macro that takes every name from sheet two and checks if it is
in
the current header row of sheet one. IF SO, I want the macro to select
the
cells under that column header for as far the column is filled with
values.
-With this selection made by the macro, I than want to perform another
action (maybe copying it to another section of the workbook or maybe give
the selected range a name - but that is something I have to look at
later).

Anybody able to help?

Regards,
Harry









  #6   Report Post  
Posted to microsoft.public.excel.misc
Harry
 
Posts: n/a
Default question on macro

btw,
in my email below, the underscores miss, but in excel i have the linebreaks
correct....

"Harry" schreef in bericht
...
JMB,

I managed to get this macro working ones. It was giving me all ranges in a
message box.
But after that first time I keep getting an error message when it reaches
"For Each x In .Range".
The error says something like "Error 424 during execution, object needed"

The complete test of the macro in my actual workbook reads :

Sub test()
Dim x As Range
Dim FoundCell As Range

With Blad2
For Each x In .Range("A1", .Cells(.Rows.Count, 1).End(xlUp))
With Blad1.Rows("1:1")
Set FoundCell = .Find(what:=x.Value, after:=.Cells(1, 1),
LookIn:=xlValues, lookat:=xlWhole, searchorder:=xlByRows,
searchdirection:=xlNext, MatchCase:=False, matchbyte:=False)
If Not FoundCell Is Nothing Then
With .Parent
MsgBox .Range(FoundCell, .Cells(.Rows.Count,
FoundCell.Column).End(xlUp)).Address
End With
Else: MsgBox "Not Found"
End If
End With
Next x
End With

End Sub



  #7   Report Post  
Posted to microsoft.public.excel.misc
Harry
 
Posts: n/a
Default question on macro

JMB,

Thx again.

I made a mistake with the "Sheet1" / "Blad1" naming. That is why it did not
work after the first use. That is fixed now.

Now I am looking at the part with the output to the message box. That I want
to change in something that pastes every single selected range in a new
"Sheet3" and preparing new columns from left to right with those ranges..
Will have to figure that out. Maybe you can help again ;-)

Next, I want a good tutorial on the web for VBA/excel. Most that I did find
with google seem to be very superficial. And I need more like the macro you
did give me.
Any tips for that?

Harry


"Harry" schreef in bericht
...
JMB,

I managed to get this macro working ones. It was giving me all ranges in a
message box.
But after that first time I keep getting an error message when it reaches
"For Each x In .Range".
The error says something like "Error 424 during execution, object needed"

The complete test of the macro in my actual workbook reads :

Sub test()
Dim x As Range
Dim FoundCell As Range

With Blad2
For Each x In .Range("A1", .Cells(.Rows.Count, 1).End(xlUp))
With Blad1.Rows("1:1")
Set FoundCell = .Find(what:=x.Value, after:=.Cells(1, 1),
LookIn:=xlValues, lookat:=xlWhole, searchorder:=xlByRows,
searchdirection:=xlNext, MatchCase:=False, matchbyte:=False)
If Not FoundCell Is Nothing Then
With .Parent
MsgBox .Range(FoundCell, .Cells(.Rows.Count,
FoundCell.Column).End(xlUp)).Address
End With
Else: MsgBox "Not Found"
End If
End With
Next x
End With

End Sub

The only thing altered was that in my Dutch excel, a sheet is called
"Blad".
Any idea why it worked once and not again????

Harry



"JMB" schreef in bericht
...
One way to find the range(s). It just gives a message box with the range
address -change when you decide what you want to do with it. Note I'm
using
the codenames for the worksheets (check VBA help for more info). I'm
assuming your list is on Sheet2 Column A and the headers of the imported
data
is on Shee1, Row1. Hope it helps.

Sub test()
Dim x As Range
Dim FoundCell As Range

With Sheet2
For Each x In .Range("A1", _
.Cells(.Rows.Count, 1).End(xlUp))
With Sheet1.Rows("1:1")
Set FoundCell = .Find(what:=x.Value, _
after:=.Cells(1, 1), LookIn:=xlValues, _
lookat:=xlWhole, searchorder:=xlByRows, _
searchdirection:=xlNext, MatchCase:=False, _
matchbyte:=False)
If Not FoundCell Is Nothing Then
With .Parent
MsgBox .Range(FoundCell, .Cells(.Rows.Count, _
FoundCell.Column).End(xlUp)).Address
End With
Else: MsgBox "Not Found"
End If
End With
Next x
End With

End Sub


"Harry" wrote:

Hi,

I have a spreadsheet at hand that is an output from a lab computer.
Until
now, I had to do some simple calculations with excel on this sheet. But
in
future I want to do more. For this I need a simple (I think) solution
for
a
problem. But it seems I cannot find how to do that :-)

In essence it comes down to this:

-I have a workbook with two sheets.
-In sheet one is the output file (xls) from a laboratory machine. This
consists mainly of multiple colums with each a unique text header in
the
top row. Each column has a variable number of cells depending on what
analysis is done by the lab machine. It can be 10 cells or 100 cells
under
each header. In practice this means that sheet one can consist of
anything
from 2 to 400 rows with all numbers possible in between.
-In sheet two I have a list in one column of all possible column headers
that could be found in sheet 1 (this is made up by an total output list
from
the lab machine).
Note that not from every analysis, all header names are put in sheet
one.
That depends on the analysis again.
So the total list on sheet two can be 200 names long while the output
from
the
labmachine to sheet one could consist of e.g. only of these 20 headers
with
a variable
number of cells under each header.
-I want a macro that takes every name from sheet two and checks if it is
in
the current header row of sheet one. IF SO, I want the macro to select
the
cells under that column header for as far the column is filled with
values.
-With this selection made by the macro, I than want to perform another
action (maybe copying it to another section of the workbook or maybe
give
the selected range a name - but that is something I have to look at
later).

Anybody able to help?

Regards,
Harry









  #8   Report Post  
Posted to microsoft.public.excel.misc
JMB
 
Posts: n/a
Default question on macro

Using the same code I posted earlier (so you'll need to change references as
needed). I'm assuming you want Sheet3 cleared before copying everthing over.
If that is not the case, delete the statement that clears Sheet3. The
changes are and IF/THEN/ELSE statement after the With .Parent line, and I
deleted the Else:Msgbox "Not Found" line (figured you probably don't need,
but if you want to do something different, you can leave the else in and do
something different than a msgbox).

This forum is a good source for learning new things, you can also try

mvps.org
xldynamic.com
mcgimpsey.com

Many include their website links w/their posts.

Sub test()
Dim x As Range
Dim FoundCell As Range

Sheet3.Cells.Clear

With Sheet2
For Each x In .Range("A1", _
.Cells(.Rows.Count, 1).End(xlUp))
With Sheet1.Rows("1:1")
Set FoundCell = .Find(what:=x.Value, _
after:=.Cells(1, 1), LookIn:=xlValues, _
lookat:=xlWhole, searchorder:=xlByRows, _
searchdirection:=xlNext, MatchCase:=False, _
matchbyte:=False)
If Not FoundCell Is Nothing Then
With .Parent
If IsEmpty(Sheet3.Cells(1, 1)) Then
.Range(FoundCell, .Cells(.Rows.Count, _
FoundCell.Column).End(xlUp)).Copy _
Sheet3.Cells(1, 1)
Else: .Range(FoundCell, .Cells(.Rows.Count, _
FoundCell.Column).End(xlUp)).Copy _
Sheet3.Cells(1, Sheet3.Columns.Count).End(xlToLeft)(1, 2)
End If
End With
End If
End With
Next x
End With

End Sub

"Harry" wrote:

JMB,

Thx again.

I made a mistake with the "Sheet1" / "Blad1" naming. That is why it did not
work after the first use. That is fixed now.

Now I am looking at the part with the output to the message box. That I want
to change in something that pastes every single selected range in a new
"Sheet3" and preparing new columns from left to right with those ranges..
Will have to figure that out. Maybe you can help again ;-)

Next, I want a good tutorial on the web for VBA/excel. Most that I did find
with google seem to be very superficial. And I need more like the macro you
did give me.
Any tips for that?

Harry


"Harry" schreef in bericht
...
JMB,

I managed to get this macro working ones. It was giving me all ranges in a
message box.
But after that first time I keep getting an error message when it reaches
"For Each x In .Range".
The error says something like "Error 424 during execution, object needed"

The complete test of the macro in my actual workbook reads :

Sub test()
Dim x As Range
Dim FoundCell As Range

With Blad2
For Each x In .Range("A1", .Cells(.Rows.Count, 1).End(xlUp))
With Blad1.Rows("1:1")
Set FoundCell = .Find(what:=x.Value, after:=.Cells(1, 1),
LookIn:=xlValues, lookat:=xlWhole, searchorder:=xlByRows,
searchdirection:=xlNext, MatchCase:=False, matchbyte:=False)
If Not FoundCell Is Nothing Then
With .Parent
MsgBox .Range(FoundCell, .Cells(.Rows.Count,
FoundCell.Column).End(xlUp)).Address
End With
Else: MsgBox "Not Found"
End If
End With
Next x
End With

End Sub

The only thing altered was that in my Dutch excel, a sheet is called
"Blad".
Any idea why it worked once and not again????

Harry



"JMB" schreef in bericht
...
One way to find the range(s). It just gives a message box with the range
address -change when you decide what you want to do with it. Note I'm
using
the codenames for the worksheets (check VBA help for more info). I'm
assuming your list is on Sheet2 Column A and the headers of the imported
data
is on Shee1, Row1. Hope it helps.

Sub test()
Dim x As Range
Dim FoundCell As Range

With Sheet2
For Each x In .Range("A1", _
.Cells(.Rows.Count, 1).End(xlUp))
With Sheet1.Rows("1:1")
Set FoundCell = .Find(what:=x.Value, _
after:=.Cells(1, 1), LookIn:=xlValues, _
lookat:=xlWhole, searchorder:=xlByRows, _
searchdirection:=xlNext, MatchCase:=False, _
matchbyte:=False)
If Not FoundCell Is Nothing Then
With .Parent
MsgBox .Range(FoundCell, .Cells(.Rows.Count, _
FoundCell.Column).End(xlUp)).Address
End With
Else: MsgBox "Not Found"
End If
End With
Next x
End With

End Sub


"Harry" wrote:

Hi,

I have a spreadsheet at hand that is an output from a lab computer.
Until
now, I had to do some simple calculations with excel on this sheet. But
in
future I want to do more. For this I need a simple (I think) solution
for
a
problem. But it seems I cannot find how to do that :-)

In essence it comes down to this:

-I have a workbook with two sheets.
-In sheet one is the output file (xls) from a laboratory machine. This
consists mainly of multiple colums with each a unique text header in
the
top row. Each column has a variable number of cells depending on what
analysis is done by the lab machine. It can be 10 cells or 100 cells
under
each header. In practice this means that sheet one can consist of
anything
from 2 to 400 rows with all numbers possible in between.
-In sheet two I have a list in one column of all possible column headers
that could be found in sheet 1 (this is made up by an total output list
from
the lab machine).
Note that not from every analysis, all header names are put in sheet
one.
That depends on the analysis again.
So the total list on sheet two can be 200 names long while the output
from
the
labmachine to sheet one could consist of e.g. only of these 20 headers
with
a variable
number of cells under each header.
-I want a macro that takes every name from sheet two and checks if it is
in
the current header row of sheet one. IF SO, I want the macro to select
the
cells under that column header for as far the column is filled with
values.
-With this selection made by the macro, I than want to perform another
action (maybe copying it to another section of the workbook or maybe
give
the selected range a name - but that is something I have to look at
later).

Anybody able to help?

Regards,
Harry










  #9   Report Post  
Posted to microsoft.public.excel.misc
Harry
 
Posts: n/a
Default question on macro

Thanks again from Holland JMB!!!!

I will study your code and let you know if it worked! Looks good however!

Harry


"JMB" schreef in bericht
...
Using the same code I posted earlier (so you'll need to change references
as
needed). I'm assuming you want Sheet3 cleared before copying everthing
over.
If that is not the case, delete the statement that clears Sheet3. The
changes are and IF/THEN/ELSE statement after the With .Parent line, and I
deleted the Else:Msgbox "Not Found" line (figured you probably don't need,
but if you want to do something different, you can leave the else in and
do
something different than a msgbox).

This forum is a good source for learning new things, you can also try

mvps.org
xldynamic.com
mcgimpsey.com

Many include their website links w/their posts.

Sub test()
Dim x As Range
Dim FoundCell As Range

Sheet3.Cells.Clear

With Sheet2
For Each x In .Range("A1", _
.Cells(.Rows.Count, 1).End(xlUp))
With Sheet1.Rows("1:1")
Set FoundCell = .Find(what:=x.Value, _
after:=.Cells(1, 1), LookIn:=xlValues, _
lookat:=xlWhole, searchorder:=xlByRows, _
searchdirection:=xlNext, MatchCase:=False, _
matchbyte:=False)
If Not FoundCell Is Nothing Then
With .Parent
If IsEmpty(Sheet3.Cells(1, 1)) Then
.Range(FoundCell, .Cells(.Rows.Count, _
FoundCell.Column).End(xlUp)).Copy _
Sheet3.Cells(1, 1)
Else: .Range(FoundCell, .Cells(.Rows.Count, _
FoundCell.Column).End(xlUp)).Copy _
Sheet3.Cells(1, Sheet3.Columns.Count).End(xlToLeft)(1, 2)
End If
End With
End If
End With
Next x
End With

End Sub

"Harry" wrote:

JMB,

Thx again.

I made a mistake with the "Sheet1" / "Blad1" naming. That is why it did
not
work after the first use. That is fixed now.

Now I am looking at the part with the output to the message box. That I
want
to change in something that pastes every single selected range in a new
"Sheet3" and preparing new columns from left to right with those ranges..
Will have to figure that out. Maybe you can help again ;-)

Next, I want a good tutorial on the web for VBA/excel. Most that I did
find
with google seem to be very superficial. And I need more like the macro
you
did give me.
Any tips for that?

Harry


"Harry" schreef in bericht
...
JMB,

I managed to get this macro working ones. It was giving me all ranges
in a
message box.
But after that first time I keep getting an error message when it
reaches
"For Each x In .Range".
The error says something like "Error 424 during execution, object
needed"

The complete test of the macro in my actual workbook reads :

Sub test()
Dim x As Range
Dim FoundCell As Range

With Blad2
For Each x In .Range("A1", .Cells(.Rows.Count, 1).End(xlUp))
With Blad1.Rows("1:1")
Set FoundCell = .Find(what:=x.Value, after:=.Cells(1, 1),
LookIn:=xlValues, lookat:=xlWhole, searchorder:=xlByRows,
searchdirection:=xlNext, MatchCase:=False, matchbyte:=False)
If Not FoundCell Is Nothing Then
With .Parent
MsgBox .Range(FoundCell, .Cells(.Rows.Count,
FoundCell.Column).End(xlUp)).Address
End With
Else: MsgBox "Not Found"
End If
End With
Next x
End With

End Sub

The only thing altered was that in my Dutch excel, a sheet is called
"Blad".
Any idea why it worked once and not again????

Harry



"JMB" schreef in bericht
...
One way to find the range(s). It just gives a message box with the
range
address -change when you decide what you want to do with it. Note I'm
using
the codenames for the worksheets (check VBA help for more info). I'm
assuming your list is on Sheet2 Column A and the headers of the
imported
data
is on Shee1, Row1. Hope it helps.

Sub test()
Dim x As Range
Dim FoundCell As Range

With Sheet2
For Each x In .Range("A1", _
.Cells(.Rows.Count, 1).End(xlUp))
With Sheet1.Rows("1:1")
Set FoundCell = .Find(what:=x.Value, _
after:=.Cells(1, 1), LookIn:=xlValues, _
lookat:=xlWhole, searchorder:=xlByRows, _
searchdirection:=xlNext, MatchCase:=False, _
matchbyte:=False)
If Not FoundCell Is Nothing Then
With .Parent
MsgBox .Range(FoundCell, .Cells(.Rows.Count, _
FoundCell.Column).End(xlUp)).Address
End With
Else: MsgBox "Not Found"
End If
End With
Next x
End With

End Sub


"Harry" wrote:

Hi,

I have a spreadsheet at hand that is an output from a lab computer.
Until
now, I had to do some simple calculations with excel on this sheet.
But
in
future I want to do more. For this I need a simple (I think) solution
for
a
problem. But it seems I cannot find how to do that :-)

In essence it comes down to this:

-I have a workbook with two sheets.
-In sheet one is the output file (xls) from a laboratory machine.
This
consists mainly of multiple colums with each a unique text header in
the
top row. Each column has a variable number of cells depending on what
analysis is done by the lab machine. It can be 10 cells or 100 cells
under
each header. In practice this means that sheet one can consist of
anything
from 2 to 400 rows with all numbers possible in between.
-In sheet two I have a list in one column of all possible column
headers
that could be found in sheet 1 (this is made up by an total output
list
from
the lab machine).
Note that not from every analysis, all header names are put in sheet
one.
That depends on the analysis again.
So the total list on sheet two can be 200 names long while the output
from
the
labmachine to sheet one could consist of e.g. only of these 20
headers
with
a variable
number of cells under each header.
-I want a macro that takes every name from sheet two and checks if it
is
in
the current header row of sheet one. IF SO, I want the macro to
select
the
cells under that column header for as far the column is filled with
values.
-With this selection made by the macro, I than want to perform
another
action (maybe copying it to another section of the workbook or maybe
give
the selected range a name - but that is something I have to look at
later).

Anybody able to help?

Regards,
Harry












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
Quick Macro question - How to delete two rows then skip one - and repeat David Smithz Excel Discussion (Misc queries) 3 March 3rd 06 02:58 PM
Excel Macro Question billrl34 Excel Worksheet Functions 1 December 19th 05 10:38 PM
using a macro question revisited Adam Kroger Excel Discussion (Misc queries) 4 December 16th 05 03:37 PM
Excel Macro Question about Conditional Formatting David Britton via OfficeKB.com New Users to Excel 3 February 10th 05 02:23 PM
Attn: Dave P. Question re Pix Calls via Macro DocuMike Excel Discussion (Misc queries) 1 January 10th 05 01:38 AM


All times are GMT +1. The time now is 10:36 AM.

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

About Us

"It's about Microsoft Excel"