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

Hi, I am trying to get my macro to delete a particular column when the first
row of that column contains a certain keyword, however I am only able to
delete the first row of that column. In addition, how come " Workbooks.Open
Filename:=fi" keeps giving me error 1004 - runtime error that says it can't
find the file?

Sub redundantCols()

Dim fi As String, sh As String
Dim c As String
Dim i As Integer, j As Integer, k As Integer
fi = InputBox("Enter the name of file", "Source file")
sh = InputBox("Enter the name of the sheet", "Source sheet")
fi = fi & ".xls"

Workbooks.Open Filename:=fi
Windows(fi).Activate
Sheets(sh).Select

With Workbooks(fi).Worksheets(sh)
.Cells(1, 9) = "Item Description"
i = 1
For j = 1 To 16
c = Cells(i, j)

If c = "Description" Or c = "Item" Then
.Cells(i, j) = ""
End If

Next j

End With

End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
RWN RWN is offline
external usenet poster
 
Posts: 104
Default Delete columns

Regarding the second question (err 1004);
You have to supply the path as well as the name.

--
Regards;
Rob
------------------------------------------------------------------------
"Elsie" wrote in message
...
Hi, I am trying to get my macro to delete a particular column when the

first
row of that column contains a certain keyword, however I am only able

to
delete the first row of that column. In addition, how come "

Workbooks.Open
Filename:=fi" keeps giving me error 1004 - runtime error that says it

can't
find the file?

Sub redundantCols()

Dim fi As String, sh As String
Dim c As String
Dim i As Integer, j As Integer, k As Integer
fi = InputBox("Enter the name of file", "Source file")
sh = InputBox("Enter the name of the sheet", "Source sheet")
fi = fi & ".xls"

Workbooks.Open Filename:=fi
Windows(fi).Activate
Sheets(sh).Select

With Workbooks(fi).Worksheets(sh)
.Cells(1, 9) = "Item Description"
i = 1
For j = 1 To 16
c = Cells(i, j)

If c = "Description" Or c = "Item" Then
.Cells(i, j) = ""
End If

Next j

End With

End Sub




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
delete columns if 0 jatman New Users to Excel 2 January 3rd 09 04:39 AM
Delete Columns Bernie New Users to Excel 1 February 28th 07 10:15 PM
merge text from 2 columns into 1 then delete the old 2 columns sleepindogg Excel Worksheet Functions 4 March 30th 06 07:25 PM
I can't delete columns - help! dcleesfo Excel Worksheet Functions 3 September 16th 05 02:00 AM
Delete columns David Excel Programming 1 October 29th 03 01:25 PM


All times are GMT +1. The time now is 12:25 PM.

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"