RastaBananaa
New Member
- Joined
- Apr 23, 2018
- Messages
- 8
Hi All,
I have a problem which I have been stuck on.
I need to create a pivot table but these tables would include different information depending on what the sheet contains. For example, if it contains journal usage, journals pivot created, if contains database usage, database pivot created and so on.
So I have created the 3 separate macros to run the separate reports but I want to have the one macro to find a specific text/value in the sheet and depending on the found value, would create the according sheet.
The problem I am having is how to create a code which follows the below logic:
Look for "text1" when found do something
if not found
Look for "text2" when found do something
if not found
look for "text3" when found do something
So I been using the:
Cells.Find(what:="HTML", LookIn:=xlFormulas, _
LookAt:=xlWhole, SearchOrder:=xlByColumns, SearchDirection:=xlNext, _
MatchCase:=True).Activate
But this does not seem to work as it looks for the specific text, in this case HTML and if it does not find it, just throws an error.
I tried If cell.find..... then... but nothing. I used the find tool in Excel to see what code is needed for VBA but I can see I am going about it the wrong way.
Also, I would need the macro to look in the entire sheet and I cannot define a sheet range as it can change. I mean I can define it because maximum columns would be AB or something but I would like to avoid this.
I really hope someone can help me out. been stuck on this for months...
Thanks,
RastaBananaa
I have a problem which I have been stuck on.
I need to create a pivot table but these tables would include different information depending on what the sheet contains. For example, if it contains journal usage, journals pivot created, if contains database usage, database pivot created and so on.
So I have created the 3 separate macros to run the separate reports but I want to have the one macro to find a specific text/value in the sheet and depending on the found value, would create the according sheet.
The problem I am having is how to create a code which follows the below logic:
Look for "text1" when found do something
if not found
Look for "text2" when found do something
if not found
look for "text3" when found do something
So I been using the:
Cells.Find(what:="HTML", LookIn:=xlFormulas, _
LookAt:=xlWhole, SearchOrder:=xlByColumns, SearchDirection:=xlNext, _
MatchCase:=True).Activate
But this does not seem to work as it looks for the specific text, in this case HTML and if it does not find it, just throws an error.
I tried If cell.find..... then... but nothing. I used the find tool in Excel to see what code is needed for VBA but I can see I am going about it the wrong way.
Also, I would need the macro to look in the entire sheet and I cannot define a sheet range as it can change. I mean I can define it because maximum columns would be AB or something but I would like to avoid this.
I really hope someone can help me out. been stuck on this for months...
Thanks,
RastaBananaa