PC Review


Reply
Thread Tools Rate Thread

How do i fix this macro?

 
 
Hinojosa via OfficeKB.com
Guest
Posts: n/a
 
      11th Oct 2006
This is the macro I'm using now:

Sub copy_it()
Dim r As Range,r1 As Range, r2 As Range
Workbooks ("TMSDL.XLS").Activate
s = InputBox("Enter Search Value:")
For Each r in ActiveSheet.UsedRange
If r.Value = s Then
Set r1 = Range(r, r.Offset(0,8))
Set r2 = Workbooks("TMSPhaomReport.xls").Worksheet("TMSDL").Range("A1")

r1.Copy r2
Exit sub
End If
Next

I still learning how to use this but the problem is when I run this Macro it
doesn't do anything. I'm guessing because r doesn't equal s but not really
sure. Can anyone help me out?

--
Message posted via http://www.officekb.com

 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      11th Oct 2006
Unless you do something special, this line is case sensitive:

If r.Value = s Then

So ASDF won't match asdf or AsDf or ASDf or ASdF or...

maybe it would be as simple as:

if lcase(r.value) = lcase(s) then



"Hinojosa via OfficeKB.com" wrote:
>
> This is the macro I'm using now:
>
> Sub copy_it()
> Dim r As Range,r1 As Range, r2 As Range
> Workbooks ("TMSDL.XLS").Activate
> s = InputBox("Enter Search Value:")
> For Each r in ActiveSheet.UsedRange
> If r.Value = s Then
> Set r1 = Range(r, r.Offset(0,8))
> Set r2 = Workbooks("TMSPhaomReport.xls").Worksheet("TMSDL").Range("A1")
>
> r1.Copy r2
> Exit sub
> End If
> Next
>
> I still learning how to use this but the problem is when I run this Macro it
> doesn't do anything. I'm guessing because r doesn't equal s but not really
> sure. Can anyone help me out?
>
> --
> Message posted via http://www.officekb.com


--

Dave Peterson
 
Reply With Quote
 
Hinojosa via OfficeKB.com
Guest
Posts: n/a
 
      11th Oct 2006
Yes sir i have tried with all caps and all lowercase but still it just
doesn't do anything.

Dave Peterson wrote:
>Unless you do something special, this line is case sensitive:
>
>If r.Value = s Then
>
>So ASDF won't match asdf or AsDf or ASDf or ASdF or...
>
>maybe it would be as simple as:
>
>if lcase(r.value) = lcase(s) then
>
>> This is the macro I'm using now:
>>

>[quoted text clipped - 18 lines]
>> --
>> Message posted via http://www.officekb.com

>


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200610/1

 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      11th Oct 2006
Maybe there's a difference in what you type and what's in the cell???

(Leading/trailing/extra embedded spaces???)

"Hinojosa via OfficeKB.com" wrote:
>
> Yes sir i have tried with all caps and all lowercase but still it just
> doesn't do anything.
>
> Dave Peterson wrote:
> >Unless you do something special, this line is case sensitive:
> >
> >If r.Value = s Then
> >
> >So ASDF won't match asdf or AsDf or ASDf or ASdF or...
> >
> >maybe it would be as simple as:
> >
> >if lcase(r.value) = lcase(s) then
> >
> >> This is the macro I'm using now:
> >>

> >[quoted text clipped - 18 lines]
> >> --
> >> Message posted via http://www.officekb.com

> >

>
> --
> Message posted via OfficeKB.com
> http://www.officekb.com/Uwe/Forums.a...mming/200610/1


--

Dave Peterson
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro recorded... tabs & file names changed, macro hangs Steve Microsoft Excel Worksheet Functions 3 30th Oct 2009 11:41 AM
::: Sort macro with empty lines at the end. ::: Macro de tri avec lignes vide en bas. infojacques@gmail.com Microsoft Excel Discussion 2 5th Jul 2007 11:40 AM
Macro not showing in Tools/Macro/Macros yet show up when I goto VBA editor karll@swfab.com Microsoft Excel Programming 2 30th Mar 2007 07:48 PM
Run Macro On Open event for report and SetValue Macro has wierd error ThompsonJessical@yahoo.com Microsoft Access Macros 2 2nd Aug 2005 05:51 PM
Start Macro / Stop Macro / Restart Macro Pete Microsoft Excel Programming 2 21st Nov 2003 05:04 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:45 PM.