Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default help creating a macro

i need a macro that will be able to delete certain rows (remove them
completely, and, i.e. lets say theyre rows 1,2,3, then row 4 would
become row one), then save this workbook to the same location where it
was opened from, except with a slightly different filename (i.e.
include the words isolated at the end). now its prety simple to do,
the difficult part is that i need to do this for multiple files, from
multiple locations, the only good thing is that its always the same
rows that need to be deleted (or removed, which word you prefer): 1-19,
and row 2068. can anyone please help me??!!


---
Message posted from http://www.ExcelForum.com/

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default help creating a macro

in another workbook, list all your workbooks with their path

then you can loop through this list

Dim rng as Range, c as Range, bk as workbook
set rng = Range(Cells(1,1),cells(rows.count,1).End(xlup))
for each c in rng
set bk = workbooks.Open(c.Value)
bk.Worksheets(1).Rows(2068).Delete
bk.Worksheets(1).Range(1:19).EntireRow.Delete
bk.Save Application.Substitute(c.Value,".xls","isolated.xl s")
bk.Close Savechanges:=False
Next

--
Regards,
Tom Ogilvy


"ale700 " wrote in message
...
i need a macro that will be able to delete certain rows (remove them
completely, and, i.e. lets say theyre rows 1,2,3, then row 4 would
become row one), then save this workbook to the same location where it
was opened from, except with a slightly different filename (i.e.
include the words isolated at the end). now its prety simple to do,
the difficult part is that i need to do this for multiple files, from
multiple locations, the only good thing is that its always the same
rows that need to be deleted (or removed, which word you prefer): 1-19,
and row 2068. can anyone please help me??!!


---
Message posted from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default help creating a macro

It should be something like this. I haven't tested it:

Sub afjsdlfjasdkljf()

Dim iFile as integer
Dim FilePivot as range
Dim CurrFile as workbook

'Assuming your file paths are in Sheet1 starting from Cell A2, heading A1
Set FilePivot = Thisworkbook.Sheets("Sheet1").[A1]

'Start from row 2 e.g. A2
iFile = 1
'Run through each file path
Do while isempty(FilePivot.offset(iFile,0))=False

'Open file
Set CurrFile = workbook.open(Filepivot.offset(ifile,0))

'Delete rows
currfile.Sheet(????Name of the sheet????).rows("1:19").delete
currfile.Sheet(????Name of the sheet????).rows("2049").delete

'Save and close
CurrFile.save
Currfile.close

ifile=ifile+1
Loop

set currfile=nothing

End sub

"ale700 " wrote:

i need a macro that will be able to delete certain rows (remove them
completely, and, i.e. lets say theyre rows 1,2,3, then row 4 would
become row one), then save this workbook to the same location where it
was opened from, except with a slightly different filename (i.e.
include the words isolated at the end). now its prety simple to do,
the difficult part is that i need to do this for multiple files, from
multiple locations, the only good thing is that its always the same
rows that need to be deleted (or removed, which word you prefer): 1-19,
and row 2068. can anyone please help me??!!


---
Message posted from http://www.ExcelForum.com/


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default help creating a macro

wow, thanx a lot, it looks like theyll work great

--
Message posted from http://www.ExcelForum.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
Creating a New Macro SharonJo Excel Discussion (Misc queries) 1 April 4th 08 01:27 AM
Creating Macro Chey Excel Discussion (Misc queries) 1 January 18th 07 06:21 PM
Creating a Macro Tami[_2_] Excel Programming 3 June 11th 04 05:24 PM
Creating a Macro Lynch Excel Programming 1 May 5th 04 12:01 AM
Help Creating a Macro milton Excel Programming 3 October 21st 03 09:04 PM


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