THIS IS MY CODE HOW DO I MAKE IT SO IT ONLY RUNS ON THE INPUT TAB SO I DONT MESS UP THE WRONG TAB

alan myers

Board Regular
Joined
Oct 31, 2017
Messages
119
Office Version
  1. 365
Platform
  1. Windows
Sub saturday()
'
' saturday Macro
'

'
Cells.Select
Application.CutCopyMode = False
With Selection.Font
.Name = "Calibri"
.FontStyle = "Bold"
.Size = 11
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ThemeColor = xlThemeColorDark1
.TintAndShade = 0
.ThemeFont = xlThemeFontMinor
End With
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
Selection.Borders(xlEdgeLeft).LineStyle = xlNone
Selection.Borders(xlEdgeTop).LineStyle = xlNone
Selection.Borders(xlEdgeBottom).LineStyle = xlNone
Selection.Borders(xlEdgeRight).LineStyle = xlNone
Selection.Borders(xlInsideVertical).LineStyle = xlNone
Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorLight1
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Rows("1:1").Select
Selection.Delete Shift:=xlUp
ActiveWindow.SmallScroll Down:=15
Rows("23:24").Select
Selection.Delete Shift:=xlUp
ActiveWindow.SmallScroll Down:=21
Rows("46:46").Select
Selection.Delete Shift:=xlUp
ActiveWindow.SmallScroll Down:=21
Rows("69:69").Select
Selection.Delete Shift:=xlUp
ActiveWindow.SmallScroll Down:=24
Rows("92:92").Select
Selection.Delete Shift:=xlUp
ActiveWindow.SmallScroll Down:=24
Rows("115:115").Select
Selection.Delete Shift:=xlUp
ActiveWindow.SmallScroll Down:=24
Rows("138:139").Select
Selection.Delete Shift:=xlUp
Range("K143").Select
ActiveWindow.SmallScroll Down:=-183
Range("B1:L22").Select
Range("L22").Activate
Selection.Cut
Range("A1").Select
ActiveSheet.Paste
Columns("B:B").Select
Selection.Delete Shift:=xlToLeft
Columns("C:C").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Range("C1").Select
ActiveCell.FormulaR1C1 = "BH"
Columns("D:D").Select
Selection.Delete Shift:=xlToLeft
Range("E1").Select
ActiveCell.FormulaR1C1 = "II"
Columns("G:G").Select
Selection.Delete Shift:=xlToLeft
Columns("H:H").Select
Selection.Delete Shift:=xlToLeft
Range("I1").Select
ActiveCell.FormulaR1C1 = "TV"
Range("J1").Select
ActiveCell.FormulaR1C1 = "UT"
Range("K1").Select
ActiveCell.FormulaR1C1 = "SUN IS"
Range("L1").Select
ActiveCell.FormulaR1C1 = "SUN NY"
Range("C2").Select
ActiveCell.FormulaR1C1 = "0"
Range("E2").Select
ActiveCell.FormulaR1C1 = "0"
Range("I2").Select
ActiveCell.FormulaR1C1 = "0"
Range("J2").Select
ActiveCell.FormulaR1C1 = "0"
Range("K2").Select
ActiveCell.FormulaR1C1 = "0"
Range("L2").Select
ActiveCell.FormulaR1C1 = "0"
Range("C2").Select
Selection.AutoFill Destination:=Range("C2:C13"), Type:=xlFillDefault
Range("C2:C13").Select
Selection.AutoFill Destination:=Range("C2:C20"), Type:=xlFillDefault
Range("C2:C20").Select
Selection.AutoFill Destination:=Range("C2:C137"), Type:=xlFillDefault
Range("C2:C137").Select
ActiveWindow.SmallScroll Down:=-162
Range("E2").Select
ActiveWindow.SmallScroll Down:=-21
Selection.AutoFill Destination:=Range("E2:E137"), Type:=xlFillDefault
Range("E2:E137").Select
ActiveWindow.SmallScroll Down:=-21
Range("J107").Select
ActiveWindow.SmallScroll Down:=-66
Range("I33").Select
ActiveWindow.SmallScroll Down:=-45
Range("I2:L2").Select
Selection.AutoFill Destination:=Range("I2:L137"), Type:=xlFillDefault
Range("I2:L137").Select
ActiveWindow.SmallScroll Down:=-165
Range("N7").Select
End Sub
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Well, when you run this line of code
Cells.Select
It will select all 10 billion or so cells in your active sheet which you do not want to do.

Excel has about 1.5 million rows and thousands of columns

Explain in detail exactly what you're attempting to do
 
Upvote 0
when i am on the inputr tab as you see i delete some rows move some cell and add some cells and data but if i run this and i am on another tab is srcrews it up i want to make sure it only runs on the input tab
 
Upvote 0
Well try to put this line of code at the beginning.

Sheets("Alpha").activate

Change sheet name as needed.

Any other way would require a lot of code modifying. It's obvious I believe you used the Macro recorder to write this code. Which works but is not the best way.
 
Upvote 0
sounds like I would have to be on the input tab to make this work that is what I am trying to get away from thanks for the help any wat
 
Upvote 0
Why not this line at the top of the code...

VBA Code:
If ActiveSheet.Name <> "INPUT" Then Exit Sub

Or if you are trying to run the code while you are on another tab then this at the top

VBA Code:
Worksheets("INPUT").Activate
 
Last edited:
Upvote 0
Solution
You're welcome, we all were happy to help. Thanks for the feedback!
 
Upvote 0
sounds like I would have to be on the input tab to make this work that is what I am trying to get away from thanks for the help any wat
I gave you this:
Sheets("Alpha").activate

Change sheet name as needed.
Did you try my suggestion?
 
Upvote 0

Forum statistics

Threads
1,214,641
Messages
6,120,695
Members
448,979
Latest member
DET4492

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top