ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   macro to find cell content in sheets and make sheet active (https://www.excelbanter.com/excel-discussion-misc-queries/56162-macro-find-cell-content-sheets-make-sheet-active.html)

Nigel

macro to find cell content in sheets and make sheet active
 
Hi,

i have been really struggling with this macro. i have a PO Number.
example : 4533211/NICYC

in my po book i have up to 1000 purchase orders/ each with a unigue number.
i have set up a form and this number is set under a variable called PONumber
on every PO, the number is found in cell E13

what i need to do is this.
1.open my form and enter my PO number to find
2.press apply and the macro should take the number, and look through all of
the PO's until it finds the matching number.
3. when the number is found, stop searching and make this sheet active.

i have everything else completed ie errors etc, i just cannot get this right.

please can someone help me?

regs,

NS

Nigel

macro to find cell content in sheets and make sheet active
 
Hi again,

i thought i should mention that the number of PO's is not always 1000. they
are generated when required starting at the begining with 1 and so forth.
i have tried for i = 1 to 1000 but nothing seems to be coming to mind

regs,

NS


"Nigel" wrote:

Hi,

i have been really struggling with this macro. i have a PO Number.
example : 4533211/NICYC

in my po book i have up to 1000 purchase orders/ each with a unigue number.
i have set up a form and this number is set under a variable called PONumber
on every PO, the number is found in cell E13

what i need to do is this.
1.open my form and enter my PO number to find
2.press apply and the macro should take the number, and look through all of
the PO's until it finds the matching number.
3. when the number is found, stop searching and make this sheet active.

i have everything else completed ie errors etc, i just cannot get this right.

please can someone help me?

regs,

NS


TomHinkle

macro to find cell content in sheets and make sheet active
 
use a collection..

when your workbook opens, create a collection

in the collection you can have a key and an item.

Cycle through ALL worksheets

On each worksheet get the value of E13 and the name of the worksheet.

when you add an item to a collection, make what was in E13 the key, and the
worksheet name the item.

then you don't have to cycle through each worksheet for every sheet.. simply
reference the key item of the collection.

If that's a lot, then build a list of PO-numbers and their respective
worksheet names and put them on another worksheet tab.




"Nigel" wrote:

Hi again,

i thought i should mention that the number of PO's is not always 1000. they
are generated when required starting at the begining with 1 and so forth.
i have tried for i = 1 to 1000 but nothing seems to be coming to mind

regs,

NS


"Nigel" wrote:

Hi,

i have been really struggling with this macro. i have a PO Number.
example : 4533211/NICYC

in my po book i have up to 1000 purchase orders/ each with a unigue number.
i have set up a form and this number is set under a variable called PONumber
on every PO, the number is found in cell E13

what i need to do is this.
1.open my form and enter my PO number to find
2.press apply and the macro should take the number, and look through all of
the PO's until it finds the matching number.
3. when the number is found, stop searching and make this sheet active.

i have everything else completed ie errors etc, i just cannot get this right.

please can someone help me?

regs,

NS


Nigel

macro to find cell content in sheets and make sheet active
 
Hi Tom,

how do i do that then? will it let me view the actual sheet on demand? if i
am working with a specific po number, will it find the sheet and make it
active?

i don't know how to do what you are suggesting though. i do have a macro
that looks at another cell content but i cannot get it to work.

all i want is to enter my po number, and it will find the sheet related.


thanks in advance,


NS


"TomHinkle" wrote:

use a collection..

when your workbook opens, create a collection

in the collection you can have a key and an item.

Cycle through ALL worksheets

On each worksheet get the value of E13 and the name of the worksheet.

when you add an item to a collection, make what was in E13 the key, and the
worksheet name the item.

then you don't have to cycle through each worksheet for every sheet.. simply
reference the key item of the collection.

If that's a lot, then build a list of PO-numbers and their respective
worksheet names and put them on another worksheet tab.




"Nigel" wrote:

Hi again,

i thought i should mention that the number of PO's is not always 1000. they
are generated when required starting at the begining with 1 and so forth.
i have tried for i = 1 to 1000 but nothing seems to be coming to mind

regs,

NS


"Nigel" wrote:

Hi,

i have been really struggling with this macro. i have a PO Number.
example : 4533211/NICYC

in my po book i have up to 1000 purchase orders/ each with a unigue number.
i have set up a form and this number is set under a variable called PONumber
on every PO, the number is found in cell E13

what i need to do is this.
1.open my form and enter my PO number to find
2.press apply and the macro should take the number, and look through all of
the PO's until it finds the matching number.
3. when the number is found, stop searching and make this sheet active.

i have everything else completed ie errors etc, i just cannot get this right.

please can someone help me?

regs,

NS


Chris Gidman

Quote:

Originally Posted by Nigel (Post 189015)
how do i do that then? will it let me view the actual sheet on demand? if i
am working with a specific po number, will it find the sheet and make it
active?

Nigel,

If you are using VBA, once you find the worksheet, you need to select it to make it appear. If sheetIndex is a variable containing the name or number of the worksheet, use this:

Sheets(sheetIndex).Select()

If you post your code, perhaps the forum can provide more detailed help.

Regards.

G


All times are GMT +1. The time now is 01:44 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com