Exceeding row limit - create new sheet











up vote
2
down vote

favorite












I have 2 columns on a sheet "list", one column that lists all business entities, the other lists all org units. The functionality of the code below works perfectly but returns an error because it exceeds the sheet row limit.



The data is pasted onto a sheet "cc_act" is there a way to at point of error create a new sheet called "cc_act1"...."cc_act2" until the script is complete?



Declare Function HypMenuVRefresh Lib "HsAddin" () As Long


Sub cc()



Application.ScreenUpdating = False


Dim list As Worksheet: Set list = ThisWorkbook.Worksheets("list")
Dim p As Worksheet: Set p = ThisWorkbook.Worksheets("p")
Dim calc As Worksheet: Set calc = ThisWorkbook.Worksheets("calc")
Dim cc As Worksheet: Set cc = ThisWorkbook.Worksheets("cc_act")
Dim cc_lr As Long
Dim calc_lr As Long: calc_lr = calc.Cells(Rows.Count, "A").End(xlUp).Row
Dim calc_lc As Long: calc_lc = calc.Cells(1,
calc.Columns.Count).End(xlToLeft).Column
Dim calc_rg As Range
Dim ctry_rg As Range
Dim i As Integer
Dim x As Integer

list.Activate

For x = 2 To Range("B" & Rows.Count).End(xlUp).Row
If list.Range("B" & x).Value <> "" Then
p.Cells(17, 3) = list.Range("B" & x).Value
End If


For i = 2 To Range("A" & Rows.Count).End(xlUp).Row
If list.Range("A" & i).Value <> "" Then
p.Cells(17, 4) = list.Range("A" & i).Value
p.Calculate
End If

p.Activate
Call HypMenuVRefresh
p.Calculate

'''changes country on calc table
calc.Cells(2, 2) = p.Cells(17, 4)
calc.Cells(2, 3) = p.Cells(17, 3)
calc.Calculate
'''copy the calc range and past under last column
With calc
Set calc_rg = calc.Range("A2:F2" & calc_lr)
End With

With cc
cc_lr = cc.Cells(Rows.Count, "A").End(xlUp).Row + 1
calc_rg.Copy
cc.Cells(cc_lr, "A").PasteSpecial xlPasteValues
End With

Next i

Next x

Application.ScreenUpdating = True

End Sub









share|improve this question









New contributor




KBE11416 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
















  • 1




    You have a two-column sheet that exceeds the row limit with a combo of two fields? What version of Excel are you running? Unless you're on XL 2003, you have over a MILLION rows of business entitiy/org unit combos? What kind of business is that? How many business entities do you have? How many org units do you have? If you do the math (correctly), do you end up with over a MILLION results? I find that hard to believe for any business.
    – teylyn
    7 hours ago






  • 1




    use Long as the row counter. Integer is not large enough for row counts above 65535 rows
    – xmojmr
    3 hours ago










  • 186 entities with 369 different units, for each i am pulling 15 expense accounts per month.
    – KBE11416
    1 hour ago















up vote
2
down vote

favorite












I have 2 columns on a sheet "list", one column that lists all business entities, the other lists all org units. The functionality of the code below works perfectly but returns an error because it exceeds the sheet row limit.



The data is pasted onto a sheet "cc_act" is there a way to at point of error create a new sheet called "cc_act1"...."cc_act2" until the script is complete?



Declare Function HypMenuVRefresh Lib "HsAddin" () As Long


Sub cc()



Application.ScreenUpdating = False


Dim list As Worksheet: Set list = ThisWorkbook.Worksheets("list")
Dim p As Worksheet: Set p = ThisWorkbook.Worksheets("p")
Dim calc As Worksheet: Set calc = ThisWorkbook.Worksheets("calc")
Dim cc As Worksheet: Set cc = ThisWorkbook.Worksheets("cc_act")
Dim cc_lr As Long
Dim calc_lr As Long: calc_lr = calc.Cells(Rows.Count, "A").End(xlUp).Row
Dim calc_lc As Long: calc_lc = calc.Cells(1,
calc.Columns.Count).End(xlToLeft).Column
Dim calc_rg As Range
Dim ctry_rg As Range
Dim i As Integer
Dim x As Integer

list.Activate

For x = 2 To Range("B" & Rows.Count).End(xlUp).Row
If list.Range("B" & x).Value <> "" Then
p.Cells(17, 3) = list.Range("B" & x).Value
End If


For i = 2 To Range("A" & Rows.Count).End(xlUp).Row
If list.Range("A" & i).Value <> "" Then
p.Cells(17, 4) = list.Range("A" & i).Value
p.Calculate
End If

p.Activate
Call HypMenuVRefresh
p.Calculate

'''changes country on calc table
calc.Cells(2, 2) = p.Cells(17, 4)
calc.Cells(2, 3) = p.Cells(17, 3)
calc.Calculate
'''copy the calc range and past under last column
With calc
Set calc_rg = calc.Range("A2:F2" & calc_lr)
End With

With cc
cc_lr = cc.Cells(Rows.Count, "A").End(xlUp).Row + 1
calc_rg.Copy
cc.Cells(cc_lr, "A").PasteSpecial xlPasteValues
End With

Next i

Next x

Application.ScreenUpdating = True

End Sub









share|improve this question









New contributor




KBE11416 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
















  • 1




    You have a two-column sheet that exceeds the row limit with a combo of two fields? What version of Excel are you running? Unless you're on XL 2003, you have over a MILLION rows of business entitiy/org unit combos? What kind of business is that? How many business entities do you have? How many org units do you have? If you do the math (correctly), do you end up with over a MILLION results? I find that hard to believe for any business.
    – teylyn
    7 hours ago






  • 1




    use Long as the row counter. Integer is not large enough for row counts above 65535 rows
    – xmojmr
    3 hours ago










  • 186 entities with 369 different units, for each i am pulling 15 expense accounts per month.
    – KBE11416
    1 hour ago













up vote
2
down vote

favorite









up vote
2
down vote

favorite











I have 2 columns on a sheet "list", one column that lists all business entities, the other lists all org units. The functionality of the code below works perfectly but returns an error because it exceeds the sheet row limit.



The data is pasted onto a sheet "cc_act" is there a way to at point of error create a new sheet called "cc_act1"...."cc_act2" until the script is complete?



Declare Function HypMenuVRefresh Lib "HsAddin" () As Long


Sub cc()



Application.ScreenUpdating = False


Dim list As Worksheet: Set list = ThisWorkbook.Worksheets("list")
Dim p As Worksheet: Set p = ThisWorkbook.Worksheets("p")
Dim calc As Worksheet: Set calc = ThisWorkbook.Worksheets("calc")
Dim cc As Worksheet: Set cc = ThisWorkbook.Worksheets("cc_act")
Dim cc_lr As Long
Dim calc_lr As Long: calc_lr = calc.Cells(Rows.Count, "A").End(xlUp).Row
Dim calc_lc As Long: calc_lc = calc.Cells(1,
calc.Columns.Count).End(xlToLeft).Column
Dim calc_rg As Range
Dim ctry_rg As Range
Dim i As Integer
Dim x As Integer

list.Activate

For x = 2 To Range("B" & Rows.Count).End(xlUp).Row
If list.Range("B" & x).Value <> "" Then
p.Cells(17, 3) = list.Range("B" & x).Value
End If


For i = 2 To Range("A" & Rows.Count).End(xlUp).Row
If list.Range("A" & i).Value <> "" Then
p.Cells(17, 4) = list.Range("A" & i).Value
p.Calculate
End If

p.Activate
Call HypMenuVRefresh
p.Calculate

'''changes country on calc table
calc.Cells(2, 2) = p.Cells(17, 4)
calc.Cells(2, 3) = p.Cells(17, 3)
calc.Calculate
'''copy the calc range and past under last column
With calc
Set calc_rg = calc.Range("A2:F2" & calc_lr)
End With

With cc
cc_lr = cc.Cells(Rows.Count, "A").End(xlUp).Row + 1
calc_rg.Copy
cc.Cells(cc_lr, "A").PasteSpecial xlPasteValues
End With

Next i

Next x

Application.ScreenUpdating = True

End Sub









share|improve this question









New contributor




KBE11416 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











I have 2 columns on a sheet "list", one column that lists all business entities, the other lists all org units. The functionality of the code below works perfectly but returns an error because it exceeds the sheet row limit.



The data is pasted onto a sheet "cc_act" is there a way to at point of error create a new sheet called "cc_act1"...."cc_act2" until the script is complete?



Declare Function HypMenuVRefresh Lib "HsAddin" () As Long


Sub cc()



Application.ScreenUpdating = False


Dim list As Worksheet: Set list = ThisWorkbook.Worksheets("list")
Dim p As Worksheet: Set p = ThisWorkbook.Worksheets("p")
Dim calc As Worksheet: Set calc = ThisWorkbook.Worksheets("calc")
Dim cc As Worksheet: Set cc = ThisWorkbook.Worksheets("cc_act")
Dim cc_lr As Long
Dim calc_lr As Long: calc_lr = calc.Cells(Rows.Count, "A").End(xlUp).Row
Dim calc_lc As Long: calc_lc = calc.Cells(1,
calc.Columns.Count).End(xlToLeft).Column
Dim calc_rg As Range
Dim ctry_rg As Range
Dim i As Integer
Dim x As Integer

list.Activate

For x = 2 To Range("B" & Rows.Count).End(xlUp).Row
If list.Range("B" & x).Value <> "" Then
p.Cells(17, 3) = list.Range("B" & x).Value
End If


For i = 2 To Range("A" & Rows.Count).End(xlUp).Row
If list.Range("A" & i).Value <> "" Then
p.Cells(17, 4) = list.Range("A" & i).Value
p.Calculate
End If

p.Activate
Call HypMenuVRefresh
p.Calculate

'''changes country on calc table
calc.Cells(2, 2) = p.Cells(17, 4)
calc.Cells(2, 3) = p.Cells(17, 3)
calc.Calculate
'''copy the calc range and past under last column
With calc
Set calc_rg = calc.Range("A2:F2" & calc_lr)
End With

With cc
cc_lr = cc.Cells(Rows.Count, "A").End(xlUp).Row + 1
calc_rg.Copy
cc.Cells(cc_lr, "A").PasteSpecial xlPasteValues
End With

Next i

Next x

Application.ScreenUpdating = True

End Sub






excel vba excel-vba






share|improve this question









New contributor




KBE11416 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




KBE11416 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited 6 hours ago









Pᴇʜ

18.7k42549




18.7k42549






New contributor




KBE11416 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 10 hours ago









KBE11416

111




111




New contributor




KBE11416 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





KBE11416 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






KBE11416 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








  • 1




    You have a two-column sheet that exceeds the row limit with a combo of two fields? What version of Excel are you running? Unless you're on XL 2003, you have over a MILLION rows of business entitiy/org unit combos? What kind of business is that? How many business entities do you have? How many org units do you have? If you do the math (correctly), do you end up with over a MILLION results? I find that hard to believe for any business.
    – teylyn
    7 hours ago






  • 1




    use Long as the row counter. Integer is not large enough for row counts above 65535 rows
    – xmojmr
    3 hours ago










  • 186 entities with 369 different units, for each i am pulling 15 expense accounts per month.
    – KBE11416
    1 hour ago














  • 1




    You have a two-column sheet that exceeds the row limit with a combo of two fields? What version of Excel are you running? Unless you're on XL 2003, you have over a MILLION rows of business entitiy/org unit combos? What kind of business is that? How many business entities do you have? How many org units do you have? If you do the math (correctly), do you end up with over a MILLION results? I find that hard to believe for any business.
    – teylyn
    7 hours ago






  • 1




    use Long as the row counter. Integer is not large enough for row counts above 65535 rows
    – xmojmr
    3 hours ago










  • 186 entities with 369 different units, for each i am pulling 15 expense accounts per month.
    – KBE11416
    1 hour ago








1




1




You have a two-column sheet that exceeds the row limit with a combo of two fields? What version of Excel are you running? Unless you're on XL 2003, you have over a MILLION rows of business entitiy/org unit combos? What kind of business is that? How many business entities do you have? How many org units do you have? If you do the math (correctly), do you end up with over a MILLION results? I find that hard to believe for any business.
– teylyn
7 hours ago




You have a two-column sheet that exceeds the row limit with a combo of two fields? What version of Excel are you running? Unless you're on XL 2003, you have over a MILLION rows of business entitiy/org unit combos? What kind of business is that? How many business entities do you have? How many org units do you have? If you do the math (correctly), do you end up with over a MILLION results? I find that hard to believe for any business.
– teylyn
7 hours ago




1




1




use Long as the row counter. Integer is not large enough for row counts above 65535 rows
– xmojmr
3 hours ago




use Long as the row counter. Integer is not large enough for row counts above 65535 rows
– xmojmr
3 hours ago












186 entities with 369 different units, for each i am pulling 15 expense accounts per month.
– KBE11416
1 hour ago




186 entities with 369 different units, for each i am pulling 15 expense accounts per month.
– KBE11416
1 hour ago

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});






KBE11416 is a new contributor. Be nice, and check out our Code of Conduct.










 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53368269%2fexceeding-row-limit-create-new-sheet%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes








KBE11416 is a new contributor. Be nice, and check out our Code of Conduct.










 

draft saved


draft discarded


















KBE11416 is a new contributor. Be nice, and check out our Code of Conduct.













KBE11416 is a new contributor. Be nice, and check out our Code of Conduct.












KBE11416 is a new contributor. Be nice, and check out our Code of Conduct.















 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53368269%2fexceeding-row-limit-create-new-sheet%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Volksrepublik China

How to test boost logger output in unit testing?

Write to the output between two pipeline