Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Cell cropping with a Macro or VB

I need to be able via a macro to copy only a portion of a cells contents to a
different part of the sheet. What I have is like below:-

"CLOBMIDDLETON PBL" or "CLOBDIDCOT PBL"

I need to get ride of the "PBL" part and as you can see the first part of
the cell varies in length. Is there any way to tell excel to copy till the
space?

Thanks............. Alastair.
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Cell cropping with a Macro or VB

iloc = Instr(1,activecell," ",vbTextcompare)
s = left(activecell,iloc-1)
activecell.offset(0,5).Value = s

if the part to remove is always 3 characters and a space

s = left(activecell,len(activecell)-4)
activecell.offset(0,5).value = s

--
Regards,
Tom Ogilvy


"Alastair79" wrote:

I need to be able via a macro to copy only a portion of a cells contents to a
different part of the sheet. What I have is like below:-

"CLOBMIDDLETON PBL" or "CLOBDIDCOT PBL"

I need to get ride of the "PBL" part and as you can see the first part of
the cell varies in length. Is there any way to tell excel to copy till the
space?

Thanks............. Alastair.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default Cell cropping with a Macro or VB

If PBL is always at the end of the string and preceded by a blank:

in B1 put:

=LEFT(A1,LEN(A1)-4)


and copy down.

You can then copy (Col B)/pastespecial/values into col A.

"Alastair79" wrote:

I need to be able via a macro to copy only a portion of a cells contents to a
different part of the sheet. What I have is like below:-

"CLOBMIDDLETON PBL" or "CLOBDIDCOT PBL"

I need to get ride of the "PBL" part and as you can see the first part of
the cell varies in length. Is there any way to tell excel to copy till the
space?

Thanks............. Alastair.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 67
Default Cell cropping with a Macro or VB

Hello
No real need for a macro there but anyway:
Either
Left(Range("A1").Value, Len(Range("A1").Value) - 4)
Or
MID(Range("A1").Value),1,FIND("" "",Range("A1").Value,1)-1)

will return the text without the " PBL" part.

HTH
Cordially
Pascal


"Alastair79" a écrit dans le message
de news: ...
I need to be able via a macro to copy only a portion of a cells contents to
a
different part of the sheet. What I have is like below:-

"CLOBMIDDLETON PBL" or "CLOBDIDCOT PBL"

I need to get ride of the "PBL" part and as you can see the first part of
the cell varies in length. Is there any way to tell excel to copy till the
space?

Thanks............. Alastair.





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
cropping Tim Z. Excel Discussion (Misc queries) 3 April 24th 09 09:59 PM
Why is Print Preview cropping off data? Chris Lukowski Excel Discussion (Misc queries) 0 April 17th 07 09:06 PM
Picture Cropping Challenge onceuponatime Excel Programming 0 January 5th 06 09:08 PM
Intelligent picture cropping onceuponatime Excel Programming 0 January 3rd 06 07:44 PM
Question: Cell formula or macro to write result of one cell to another cell Frederik Romanov Excel Programming 1 July 8th 03 03:03 PM


All times are GMT +1. The time now is 03:22 AM.

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"