Hi All
I am just beginner on Excel vba and need your help.
I have a sheet which has Country name field (In Column A) and their status field (In Column C).
Please see below image from my file for your reference.
IMAGE.JPG
I want macro to create a new worksheet for countries where the status is "Yes" and should name it according to that country. If the status is " No" then it should move to next country. This should continue until all the countries are checked in column A.
Eg: If the status for Australia is "Yes" then the macro should create new worksheet with name Australia, If it's no then it should move to Bahrain.
I tried below the below code (using help from internet) but it is not working.
Your help will make my work more easy
When i try to run the below macro it gives me Compile error : Next without For
Public Sub Unnamed() Dim intRowCount As Integer Dim i As Integer intRowCount = Range("a1").CurrentRegion.Rows.Count rgnrowcount = Range("c1").CurrentRegion.Rows.Count Range("a2").Select For i = 2 To intRowCount Range("c2").Select For r = 2 To rngRowCount Sheets("MACRO").Select If Range("c" & i).Value = "Yes" Then Sheets.Add ActiveSheet.Select If ActiveSheet.Name <> "" Then ActiveSheet.Name = Sheets("MACRO").Range("a" & r) Next r Next i Else End If End Sub
Bookmarks