Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Stopping errors when a find statement doesn't find! | Excel Programming | |||
View only items in the left column that have X's in right columns | Excel Discussion (Misc queries) | |||
Find Column heading and then Delete entire column | Excel Programming | |||
counting from left to right and stopping when blank | Excel Discussion (Misc queries) | |||
find and delete duplicate entries in two columns or find and prin. | Excel Programming |