Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default works on XP but not on vista

Hi I have following code to search and for specific words and then delete the
rows between ( including them) those rows.
This macro works fine on a XP machine, but not working properly on Vista.

While debugging the code by €śstep into€ť, I realized the €śWS. Find€ť function
not finding the rows, even though those words are exist in the first column.
I am trying modify the code to other than €śWS.columns.find€ť function, but
can you help me to find out why it is not working on Vista, the way it is
supposed to be?
thank you so much for your help
########
Public Sub Paste_Transpose_Specific()
Dim WS As Worksheet
Dim Trialrow, Summaryrow As Range
On Error Resume Next

For Each WS In ActiveWorkbook.Worksheets
With WS
Set Trialrow = WS.Columns(1).Find("Sample", Range("A1"),
SearchOrder:=xlByRows, SearchDirection:=xlNext)

Set Summaryrow = WS.Columns(1).Find("Total:", Range("A1"),
SearchOrder:=xlByRows, SearchDirection:=xlPrevious)

If Not (Trialrow Is Nothing) And Not (Summaryrow Is Nothing) Then _
WS.Rows(Trialrow.Row & ":" & Summaryrow.Row).Delete


End With


Next WS
On Error GoTo 0

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default works on XP but not on vista


The problem probably isn't the difference between 2003 and 2007. The
find function uses the same function as the worksheet find (2003 menu
Edit - find). the find doesn't have a default value for some of the
parameters. the find uses whatever was last set in the worksheet. So
you probably just have to add all the parameters in the find function.
OPen up the worksheet find and look at the option. You will see that it
is set incrorrectly.

expression.Find(What, After, LookIn, LookAt, SearchOrder,
SearchDirection, MatchCase, MatchByte, SearchFormat)


Usually as a mimimum you need to specfiy the

LookIn:=xlvalues, lookat:=xlwhole, MatchCase:=False

Lookat can also be xlpart


The most common failure like this is the Part vs Whole


--
joel
------------------------------------------------------------------------
joel's Profile: http://www.thecodecage.com/forumz/member.php?userid=229
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=149293

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default works on XP but not on vista

additionally change this
Dim Trialrow, Summaryrow As Range

to
Dim Trialrow As Range, Summaryrow As Range


in your code, Trialrow is variant by default since you need to explicitly
set its type. However, it doesn't affect your code, I'm just being picky :)

"Sheela" wrote:

Hi I have following code to search and for specific words and then delete the
rows between ( including them) those rows.
This macro works fine on a XP machine, but not working properly on Vista.

While debugging the code by €śstep into€ť, I realized the €śWS. Find€ť function
not finding the rows, even though those words are exist in the first column.
I am trying modify the code to other than €śWS.columns.find€ť function, but
can you help me to find out why it is not working on Vista, the way it is
supposed to be?
thank you so much for your help
########
Public Sub Paste_Transpose_Specific()
Dim WS As Worksheet
Dim Trialrow, Summaryrow As Range
On Error Resume Next

For Each WS In ActiveWorkbook.Worksheets
With WS
Set Trialrow = WS.Columns(1).Find("Sample", Range("A1"),
SearchOrder:=xlByRows, SearchDirection:=xlNext)

Set Summaryrow = WS.Columns(1).Find("Total:", Range("A1"),
SearchOrder:=xlByRows, SearchDirection:=xlPrevious)

If Not (Trialrow Is Nothing) And Not (Summaryrow Is Nothing) Then _
WS.Rows(Trialrow.Row & ":" & Summaryrow.Row).Delete


End With


Next WS
On Error GoTo 0

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default works on XP but not on vista

Thank you so much for your help, it worked.
sheela
"joel" wrote:


The problem probably isn't the difference between 2003 and 2007. The
find function uses the same function as the worksheet find (2003 menu
Edit - find). the find doesn't have a default value for some of the
parameters. the find uses whatever was last set in the worksheet. So
you probably just have to add all the parameters in the find function.
OPen up the worksheet find and look at the option. You will see that it
is set incrorrectly.

expression.Find(What, After, LookIn, LookAt, SearchOrder,
SearchDirection, MatchCase, MatchByte, SearchFormat)


Usually as a mimimum you need to specfiy the

LookIn:=xlvalues, lookat:=xlwhole, MatchCase:=False

Lookat can also be xlpart


The most common failure like this is the Part vs Whole


--
joel
------------------------------------------------------------------------
joel's Profile: http://www.thecodecage.com/forumz/member.php?userid=229
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=149293

.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default works on XP but not on vista

I did not know that defining variables in one row vs. separate rows makes a
difference.

I changed the all the definitions in my code each one in a separate line.
thank you.

sheela

"Patrick Molloy" wrote:

additionally change this
Dim Trialrow, Summaryrow As Range

to
Dim Trialrow As Range, Summaryrow As Range


in your code, Trialrow is variant by default since you need to explicitly
set its type. However, it doesn't affect your code, I'm just being picky :)

"Sheela" wrote:

Hi I have following code to search and for specific words and then delete the
rows between ( including them) those rows.
This macro works fine on a XP machine, but not working properly on Vista.

While debugging the code by €śstep into€ť, I realized the €śWS. Find€ť function
not finding the rows, even though those words are exist in the first column.
I am trying modify the code to other than €śWS.columns.find€ť function, but
can you help me to find out why it is not working on Vista, the way it is
supposed to be?
thank you so much for your help
########
Public Sub Paste_Transpose_Specific()
Dim WS As Worksheet
Dim Trialrow, Summaryrow As Range
On Error Resume Next

For Each WS In ActiveWorkbook.Worksheets
With WS
Set Trialrow = WS.Columns(1).Find("Sample", Range("A1"),
SearchOrder:=xlByRows, SearchDirection:=xlNext)

Set Summaryrow = WS.Columns(1).Find("Total:", Range("A1"),
SearchOrder:=xlByRows, SearchDirection:=xlPrevious)

If Not (Trialrow Is Nothing) And Not (Summaryrow Is Nothing) Then _
WS.Rows(Trialrow.Row & ":" & Summaryrow.Row).Delete


End With


Next WS
On Error GoTo 0



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default works on XP but not on vista

you can certainly dimension variables in a row..

DIM a as long, b as long, c as long

is the same as

DIM a as long
DIM b as long
DIM c as long

but
DIM a, b, c as long

only dims the last variable,c, explcitly as long. Both a and b are variants
since they are not explicitly typed.




"Sheela" wrote:

I did not know that defining variables in one row vs. separate rows makes a
difference.

I changed the all the definitions in my code each one in a separate line.
thank you.

sheela

"Patrick Molloy" wrote:

additionally change this
Dim Trialrow, Summaryrow As Range

to
Dim Trialrow As Range, Summaryrow As Range


in your code, Trialrow is variant by default since you need to explicitly
set its type. However, it doesn't affect your code, I'm just being picky :)

"Sheela" wrote:

Hi I have following code to search and for specific words and then delete the
rows between ( including them) those rows.
This macro works fine on a XP machine, but not working properly on Vista.

While debugging the code by €śstep into€ť, I realized the €śWS. Find€ť function
not finding the rows, even though those words are exist in the first column.
I am trying modify the code to other than €śWS.columns.find€ť function, but
can you help me to find out why it is not working on Vista, the way it is
supposed to be?
thank you so much for your help
########
Public Sub Paste_Transpose_Specific()
Dim WS As Worksheet
Dim Trialrow, Summaryrow As Range
On Error Resume Next

For Each WS In ActiveWorkbook.Worksheets
With WS
Set Trialrow = WS.Columns(1).Find("Sample", Range("A1"),
SearchOrder:=xlByRows, SearchDirection:=xlNext)

Set Summaryrow = WS.Columns(1).Find("Total:", Range("A1"),
SearchOrder:=xlByRows, SearchDirection:=xlPrevious)

If Not (Trialrow Is Nothing) And Not (Summaryrow Is Nothing) Then _
WS.Rows(Trialrow.Row & ":" & Summaryrow.Row).Delete


End With


Next WS
On Error GoTo 0

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default works on XP but not on vista


Patrick Molloy: I don't think Sheela was refering to the Dim statements.
Sheela was refering to the properties of the VBA Find. That setting
the properties in one Find to (ie xlpart) means that the following Find
statments would also use xlpart not xlwhole. VBA find is unlike other
methods that is doesn't use a default setting, instead it use the last
setting which could also include any time the FIND is used in the
worksheet menu.


--
joel
------------------------------------------------------------------------
joel's Profile: http://www.thecodecage.com/forumz/member.php?userid=229
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=149293

<a href="http://www.thecodecage.com">Microsoft Office Help</a>

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 789
Default works on XP but not on vista

I think she was Patrick!
Paul

On Nov 2, 1:25*pm, joel wrote:
Patrick Molloy: I don't think Sheela was refering to the Dim statements.
Sheela was refering to the properties of the VBA Find. *That setting
the properties in one Find to (ie xlpart) means that the following Find
statments would also use xlpart not xlwhole. *VBA find is unlike other
methods that is doesn't use a default setting, instead it use the last
setting which could also include any time the FIND is used in the
worksheet menu.

--
joel
------------------------------------------------------------------------
joel's Profile:http://www.thecodecage.com/forumz/member.php?userid=229
View this thread:http://www.thecodecage.com/forumz/sh...d.php?t=149293

<a href="http://www.thecodecage.com"MicrosoftOffice Help</a>


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
vista ramone Setting up and Configuration of Excel 2 September 28th 08 12:40 AM
Macros: Step Thru Works, Run Works, Keyboard Shortcut Locks up BEEJAY Excel Programming 2 October 3rd 06 06:46 PM
Excel Addin works that works on a template workbook s.jay_k Excel Programming 0 February 15th 06 07:31 PM
it works, it doesn work, its works....and so on. Naz Excel Programming 6 September 30th 05 01:52 PM
How do I convert works file to excel without works software? CatMB Excel Discussion (Misc queries) 1 June 21st 05 04:12 PM


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

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"