PC Review


Reply
Thread Tools Rate Thread

I am new to VBA - Help needed on Macro

 
 
mat@whs-halo.co.uk
Guest
Posts: n/a
 
      25th Apr 2008
Although I consider myself fairly good with Excel (I use 2003) I have
never used VBA.

I want to achieve something and feel a macro is the only way I can
achieve it.

Imagine I have the following in Excel:

1 A B C D
2 test 0
3 abc 0
4 abc123 1
5 something 1
6 text 1
7 hello 0

I want a cell, say, D1, to display the corresponding text in column A
for where it finds the first instance of a '1' in the B column. So it
would find a 1 in B4 and therefore display the text 'abc123' in cell
D1. It would then stop looking and ignore the 1's in B5 and B6.

Any help in this would be greatly appreciated!

Many thanks,
Mat G
Birmingham, UK
 
Reply With Quote
 
 
 
 
Mike H
Guest
Posts: n/a
 
      25th Apr 2008
Hi,

No need for a macro, try this

=INDEX($A$1:$A$6,MATCH(1,$B$1:$B$6,FALSE),1)

The 1 (in the middle of the formula) could and would be better replaced with
a cell reference.

Mike

"(E-Mail Removed)" wrote:

> Although I consider myself fairly good with Excel (I use 2003) I have
> never used VBA.
>
> I want to achieve something and feel a macro is the only way I can
> achieve it.
>
> Imagine I have the following in Excel:
>
> 1 A B C D
> 2 test 0
> 3 abc 0
> 4 abc123 1
> 5 something 1
> 6 text 1
> 7 hello 0
>
> I want a cell, say, D1, to display the corresponding text in column A
> for where it finds the first instance of a '1' in the B column. So it
> would find a 1 in B4 and therefore display the text 'abc123' in cell
> D1. It would then stop looking and ignore the 1's in B5 and B6.
>
> Any help in this would be greatly appreciated!
>
> Many thanks,
> Mat G
> Birmingham, UK
>

 
Reply With Quote
 
mat@whs-halo.co.uk
Guest
Posts: n/a
 
      25th Apr 2008
That is brilliant - just what I needed! I have never used that feature
before - every day is a school day!!

Thanks again,

Mat


On Apr 25, 12:40*pm, Mike H <Mi...@discussions.microsoft.com> wrote:
> Hi,
>
> No need for a macro, try this
>
> =INDEX($A$1:$A$6,MATCH(1,$B$1:$B$6,FALSE),1)
>
> The 1 (in the middle of the formula) could and would be better replaced with
> a cell reference.
>
> Mike
>
>
>
> "m...@whs-halo.co.uk" wrote:
> > Although I consider myself fairly good with Excel (I use 2003) I have
> > never used VBA.

>
> > I want to achieve something and feel a macro is the only way I can
> > achieve it.

>
> > Imagine I have the following in Excel:

>
> > 1 *A * * * B * * * C * * * D
> > 2 *test * *0
> > 3 *abc * * 0
> > 4 *abc123 *1
> > 5 *something * * * 1
> > 6 *text * *1
> > 7 *hello * 0

>
> > I want a cell, say, D1, to display the corresponding text in column A
> > for where it finds the first instance of a '1' in the B column. So it
> > would find a 1 in B4 and therefore display the text 'abc123' in cell
> > D1. It would then stop looking and ignore the 1's in B5 and B6.

>
> > Any help in this would be greatly appreciated!

>
> > Many thanks,
> > Mat G
> > Birmingham, UK- Hide quoted text -

>
> - Show quoted text -


 
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
PLEASE HELP! MACRO NEEDED K Microsoft Excel Programming 1 20th Jun 2009 05:53 PM
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort =?Utf-8?B?R2F2aW4=?= Microsoft Excel Worksheet Functions 0 17th May 2007 01:20 PM
Macro needed to set macro security in Excel to minimum =?Utf-8?B?Q2FybA==?= Microsoft Excel Programming 3 18th Mar 2006 03:36 PM
Macro Help needed =?Utf-8?B?dGFtYXRvNDM=?= Microsoft Excel Misc 1 19th Aug 2005 01:48 AM
Macro needed to Paste Values and prevent Macro operation thunderfoot Microsoft Excel Misc 1 11th Jun 2005 12:44 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:40 AM.