Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default prob with deleting columns

i need to create a macro to delete columns from my worksheet, which are
non-blank, and dont occur at an interval. what can be the way out for
that?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default prob with deleting columns

Can you read column titles into an array and apply your
delete/no-delete criteria based on their contents ?


ruchie wrote:
i need to create a macro to delete columns from my worksheet, which are
non-blank, and dont occur at an interval. what can be the way out for
that?


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default prob with deleting columns

since im sooo new to this, i dont know if i can do that or not. is it
possible that way?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default prob with deleting columns

Absolutely possible.. I use this type of subroutine to parse large
reports of columns that are not useful to me..

Start by creating a Title Row array of Column titles that you know are
trash..
strTitles(1) = "Garbage"
strTitles(2) = "more Garbage"
strTitles(3) = "You get the idea"

Next use a find subroutine to locate the Column and Row position of the
expected Title.
Sub FindMe(SearchWord)
SearchRow = ActiveSheet.Cells.Find(SearchWord, LookIn:=xlValues,
LookAt:= _
xlWhole).Row
SearchCol = ActiveSheet.Cells.Find(SearchWord, LookIn:=xlValues,
LookAt:= _
xlWhole).Column
End Sub

Then delete the column and advance to the next title to look for......
For z = 1 To IntLastCol
Cells(TitlesRow(1), z).Select
If IsError(Application.Match(ActiveCell.Value, strTitles, 0)) Then
Range(Cells(TitlesRow(1), z), Cells(LastRow, z)).Select
Selection.Delete Shift:=xlUp
End If
Next

Note.. you don't want to assign all of the positions at the start since
on delete your report will shift unless you use the [Selection.Delete
Shift:=xlUp] function, thereby changing the location of the columns..

Test your code first by looking for the title you expect to remove then
changing the Interior color.. you'll quickly know if your code is
working as expected.


HTH,
Will

ruchie wrote:
since im sooo new to this, i dont know if i can do that or not. is it
possible that way?


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default prob with deleting columns

thanks a ton!



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
Deleting columns Heather Setting up and Configuration of Excel 4 August 28th 09 01:44 PM
Adding Columns, Then deleting old columns May Excel Discussion (Misc queries) 4 October 30th 08 04:44 PM
Combining Text from 2 Columns into 1 then Deleting the 2 Columns sleepindogg Excel Worksheet Functions 5 September 19th 08 12:36 AM
Deleting Columns Robert Excel Programming 1 January 19th 06 02:05 PM
Deleting Columns Jim Berglund Excel Programming 2 July 20th 04 10:01 PM


All times are GMT +1. The time now is 04:30 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"