Skip worksheet in macro

PepeTheImpaler

New Member
Joined
Jun 13, 2018
Messages
3
Hello,
I have this macro and I need help. " If Worksheets.Select = "Vykazy_data" Then End", this part dont work. Pls help with solution. I need to skip one worksheet in this loop

Private Sub CommandButton2_Click()


Dim i As Integer
Dim xTCount As Variant
Dim xWs As Worksheet


Application.DisplayAlerts = False
ActiveWorkbook.Worksheets("VÝSLEDEK").Delete
Application.DisplayAlerts = True
On Error Resume Next
LInput:
xTCount = Application.InputBox("počet řádků v hlavičce", "", "1")
If TypeName(xTCount) = "Boolean" Then Exit Sub
If Not IsNumeric(xTCount) Then
MsgBox "Napiš číslo"
GoTo LInput
End If
Set xWs = ActiveWorkbook.Worksheets.Add(Sheets(1))
xWs.Name = "VÝSLEDEK"
Worksheets(1).Range("A1").EntireRow.Copy Destination:=xWs.Range("A1")




For i = 1 To Worksheets.Count


If Worksheets.Select = "Vykazy_data" Then
End
End If
Worksheets(i).Range("A1").CurrentRegion.Offset(CInt(xTCount), 0).Copy _
Destination:=xWs.Cells(xWs.UsedRange.Cells(xWs.UsedRange.Count).Row + 1, 1)


Next





End Sub
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Re: Help pls with skip worksheet in macro

Welcome to the Board!

You would want something like:
Code:
[COLOR=#333333]For i = 1 To Worksheets.Count[/COLOR]
[COLOR=#333333]    If Sheets(i).Name <> "Vykazy_data" Then
        ...continue on with rest of code here
    End If
Next i[/COLOR]
This basically skips over that needs (no reason for and "End", only do the stuff in the IF ... THEN block if the name of the sheet is NOT the one listed).
 
Upvote 0
Re: Help pls with skip worksheet in macro

Thanks for welcoming.
I am so happy to be here.

You are so helpfull mate, thank you for solution, working perfectly.
 
Upvote 0
Re: Help pls with skip worksheet in macro

You are welcome.
Glad I was able to help!:)
 
Upvote 0

Forum statistics

Threads
1,223,970
Messages
6,175,710
Members
452,667
Latest member
vanessavalentino83

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