Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Find & Delete columns to the left stopping at column B

Hi, please me with this task. I need to Find "Jan" then keep deleting
the columns to the left until "Jan" is situated in column B.

For example, "Jan" is in column E. Find "Jan" then delete columns to
the left and keep deleting until "Jan" is on column B.

Thanks very much,
Aria

*** Sent via Developersdex http://www.developersdex.com ***
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Find & Delete columns to the left stopping at column B

try this for row 3

Sub findjanandmove()
x = Rows(3).Find("Jan").Column - 1
If x = 1 Then Exit Sub
Range(Cells(3, 2), Cells(3, x)).EntireColumn.Delete
End Sub

--
Don Guillett
SalesAid Software

<Aria wrote in message ...
Hi, please me with this task. I need to Find "Jan" then keep deleting
the columns to the left until "Jan" is situated in column B.

For example, "Jan" is in column E. Find "Jan" then delete columns to
the left and keep deleting until "Jan" is on column B.

Thanks very much,
Aria

*** Sent via Developersdex
http://www.developersdex.com ***


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Find & Delete columns to the left stopping at column B

Hi Don,
Very close but I didn't want to be limited to row 3 in case finding
"Jan" is located in other rows. Any way to make the column deletions
regardless of which rows "Jan" is located?

Thanks,
Aria :)

*** Sent via Developersdex http://www.developersdex.com ***
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Find & Delete columns to the left stopping at column B

Are we to assume there will be only ONE "Jan"??

Sub findjan()
x = Cells.Find("Jan").Column - 1
If x = 1 Then Exit Sub
Range(Cells(1, 2), Cells(1, x)).EntireColumn.Delete
End Sub

--
Don Guillett
SalesAid Software

<Aria wrote in message ...
Hi Don,
Very close but I didn't want to be limited to row 3 in case finding
"Jan" is located in other rows. Any way to make the column deletions
regardless of which rows "Jan" is located?

Thanks,
Aria :)

*** Sent via Developersdex
http://www.developersdex.com ***


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Find & Delete columns to the left stopping at column B

Don,
Yes, I'm assuming that there is only one Jan throughout the document. I
tried putting in a message prior to the deletion but when I run it
again, the same message appears. Any way to stop the message from
appearing, if "Jan" is already situated in column B?


Dim mbox As Button
x = Cells.Find("Jan-*").Column - 1
If x < 1 Then
mbox = MsgBox(Prompt:="Jan will shift to column B", _
Buttons:=vbOKOnly)
Range(Cells(1, 2), Cells(1, x)).EntireColumn.delete
End If

Thanks a bunch,
Aria

*** Sent via Developersdex http://www.developersdex.com ***


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Find & Delete columns to the left stopping at column B

Then why not just insert the message and leave the rest alone

Sub findjan1()
x = Cells.Find("Jan*").Column - 1
If x = 1 Then Exit Sub
MsgBox "Jan will shift to column B"
Range(Cells(1, 2), Cells(1, x)).EntireColumn.Delete
End Sub
--
Don Guillett
SalesAid Software

<Aria wrote in message ...
Don,
Yes, I'm assuming that there is only one Jan throughout the document. I
tried putting in a message prior to the deletion but when I run it
again, the same message appears. Any way to stop the message from
appearing, if "Jan" is already situated in column B?


Dim mbox As Button
x = Cells.Find("Jan-*").Column - 1
If x < 1 Then
mbox = MsgBox(Prompt:="Jan will shift to column B", _
Buttons:=vbOKOnly)
Range(Cells(1, 2), Cells(1, x)).EntireColumn.delete
End If

Thanks a bunch,
Aria

*** Sent via Developersdex
http://www.developersdex.com ***


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Find & Delete columns to the left stopping at column B

Don,
I missed something on my previous post. Once I've found "Jan", I
changed the name. So when I ran the code again, it shouldn't find "Jan"
anymore; thus no message should appear.

Any way to stop the message from appearing, if "Jan" is not found? Or,
if "Jan" is already in Column B?

Dim mbox As Button
x = Cells.Find("Jan-*").Column - 1
If x < 1 Then
mbox = MsgBox(Prompt:="Jan will shift to column B", _
Buttons:=vbOKOnly)
Range(Cells(1, 2), Cells(1, x)).EntireColumn.delete
End If

'remaining codes here

Thanks a bunch,
Aria

*** Sent via Developersdex http://www.developersdex.com ***
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
Stopping errors when a find statement doesn't find! matpj[_34_] Excel Programming 3 January 25th 06 02:23 PM
View only items in the left column that have X's in right columns townieflo Excel Discussion (Misc queries) 2 November 23rd 05 04:12 PM
Find Column heading and then Delete entire column Kobayashi[_58_] Excel Programming 4 October 17th 05 09:09 PM
counting from left to right and stopping when blank harpscardiff Excel Discussion (Misc queries) 6 August 19th 05 07:34 PM
find and delete duplicate entries in two columns or find and prin. campare 2 columns of numbers-find unique Excel Programming 1 November 24th 04 04:09 PM


All times are GMT +1. The time now is 02:27 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"