Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default One Macro Does All


I Have 4 worksheets in a file that i use

Worksheet 1 is where i type all my data

Worksheet 2,3,4 autogenerate data from Worksheet 1

When there are lines in Column D with " v " in them i want the
deleted, i found this code that does it perfectly

Sub delete_rows()
Dim RowNdx As Long
Dim LastRow As Long
LastRow = ActiveSheet.Cells(Rows.Count, "D").End(xlUp).Row
For RowNdx = LastRow To 1 Step -1
If Cells(RowNdx, "D").Value = " v " Then
Rows(RowNdx).Delete
End If
Next RowNdx
End Sub

But it only does it when im in a worksheet , so i have to go into eac
one then run the macro, is it possible that when ive typed my data i
worksheet 1 i can run a similar macro that deletes all the rows with
v " in worksheet 2,3 & 4 all at the same time. Im guessing this i
quite easy but i dont know my way around VB at all. Many Thanks


As an additional thing when worksheets 2,3,4 have there rows deleted
save worksheet 2 as evt_test , worksheet 3 as mkt_test and worksheet
as sel_test all in CSV format, i do all this manually.

Is there a macro that i could run that dleetes my lines as above the
automatically saves these worksheets as described.

Any help is much appreciated, Thanks

--
scottymellot
-----------------------------------------------------------------------
scottymelloty's Profile: http://www.excelforum.com/member.php...nfo&userid=380
View this thread: http://www.excelforum.com/showthread.php?threadid=27148

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default One Macro Does All

Sub Multi_Sheet_delete_rows()
Dim i as Long
Dim RowNdx As Long
Dim LastRow As Long
Dim varr(2 to 4) as String
varr(2) = "evt_test.csv"
varr(3) = "mkt_test.csv"
varr(4) = "sel_test.csv"
for i = 1 to 4
worksheets(i).Activate
LastRow = ActiveSheet.Cells(Rows.Count, "D").End(xlUp).Row
For RowNdx = LastRow To 1 Step -1
If Cells(RowNdx, "D").Value = " v " Then
Rows(RowNdx).Delete
End If
Next RowNdx
if i 1 and i < 5 then
activesheet.copy
Application.DisplayAlerts = False
Activeworkbook.SaveAs "C:\Myfolder\" & _
varr(i), FileFormat:=xlCSV
Application.DisplayAlerts = True
ActiveWorkbook.Close SaveChanges:=False
End if
Next i
End Sub


--
Regards,
Tom Ogilvy

"scottymelloty" wrote in
message ...

I Have 4 worksheets in a file that i use

Worksheet 1 is where i type all my data

Worksheet 2,3,4 autogenerate data from Worksheet 1

When there are lines in Column D with " v " in them i want them
deleted, i found this code that does it perfectly

Sub delete_rows()
Dim RowNdx As Long
Dim LastRow As Long
LastRow = ActiveSheet.Cells(Rows.Count, "D").End(xlUp).Row
For RowNdx = LastRow To 1 Step -1
If Cells(RowNdx, "D").Value = " v " Then
Rows(RowNdx).Delete
End If
Next RowNdx
End Sub

But it only does it when im in a worksheet , so i have to go into each
one then run the macro, is it possible that when ive typed my data in
worksheet 1 i can run a similar macro that deletes all the rows with "
v " in worksheet 2,3 & 4 all at the same time. Im guessing this is
quite easy but i dont know my way around VB at all. Many Thanks


As an additional thing when worksheets 2,3,4 have there rows deleted i
save worksheet 2 as evt_test , worksheet 3 as mkt_test and worksheet 4
as sel_test all in CSV format, i do all this manually.

Is there a macro that i could run that dleetes my lines as above then
automatically saves these worksheets as described.

Any help is much appreciated, Thanks.


--
scottymelloty
------------------------------------------------------------------------
scottymelloty's Profile:

http://www.excelforum.com/member.php...fo&userid=3808
View this thread: http://www.excelforum.com/showthread...hreadid=271487



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
Macro recorded... tabs & file names changed, macro hangs Steve Excel Worksheet Functions 3 October 30th 09 11:41 AM
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort Gavin Excel Worksheet Functions 0 May 17th 07 01:20 PM
how to count/sum by function/macro to get the number of record to do copy/paste in macro tango Excel Programming 1 October 15th 04 01:16 PM
macro to delete entire rows when column A is blank ...a quick macro vikram Excel Programming 4 May 3rd 04 08:45 PM
Start Macro / Stop Macro / Restart Macro Pete[_13_] Excel Programming 2 November 21st 03 05:04 PM


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