Is there a way that if i hit the row limit in excel 2010 to continue adding them into a new worksheet?
Excel 2010 Worksheet size 1,048,576 rows by 16,384 columns
Sub RepeatName()
Dim state_name, president_name As String
Dim state_lstCol, president_lstCol As Long
Dim i, j, k As Integer
k = 1
Application.ScreenUpdating = False
Sheets("STATES").Select
state_lstCol = Range("A" & Rows.count).End(xlUp).Row
Sheets("PRESIDENTS").Select
president_lstCol = Range("B" & Rows.count).End(xlUp).Row
Sheets.Add
ActiveSheet.Name = "RESULT" & k
For i = 2 To state_lstCol
Sheets("STATES").Select
state_name = Range("A" & i).Value
For j = 2 To president_lstCol
Sheets("PRESIDENTS").Select
president_name = Range("B" & j).Value
Sheets("RESULT" & k).Select
ActiveCell.Formula = state_name
ActiveCell.Offset(0, 1).Formula = president_name
ActiveCell.Offset(1, 0).Select
If ActiveCell.Row = 1048576 Then
Sheets.Add
k = k + 1
ActiveSheet.Name = "RESULT" & k
End If
Next j
Next i
Application.ScreenUpdating = True
End Sub
What if i wanted to not combine them but have them in separate columns?
ActiveCell.Formula = state_name
ActiveCell.Offset(0, 1).Formula = president_name
Bookmarks