ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   One Macro Does All (https://www.excelbanter.com/excel-programming/314376-one-macro-does-all.html)

scottymelloty[_2_]

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


Tom Ogilvy

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





All times are GMT +1. The time now is 09:06 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com