Having issues with VBA adding a new line for each entry












0















I used to play around with VBA years ago and have not had a need for it until now.



Essentially I am just creating a data entry form for our production guys.



What I am trying to make happen is, each time the user clicks ok, it adds data to a new line under the previous one.



I've got it adding a line, but it just keeps overwriting the line with each click of the ok button.



Here is my code



Option Explicit

Private Sub CancelButton_Click()

Unload Me

End Sub

Private Sub ClearButton_Click()

Call UserForm_Initialize

End Sub

Private Sub OKButton_Click()

Dim emptyRow As Long

'Make Shearline active
Shearline.Activate

'Determine emptyRow
emptyRow = WorksheetFunction.CountA(Range("A:A")) + 3

'Transfer information
Cells(emptyRow, 1).Value = datebox.Value
Cells(emptyRow, 2).Value = operatorbox.Value
Cells(emptyRow, 3).Value = customerbox.Value
Cells(emptyRow, 4).Value = schedulebox.Value
Cells(emptyRow, 5).Value = barmarkbox.Value
Cells(emptyRow, 6).Value = bardialist.Value
Cells(emptyRow, 7).Value = offcutusedbox.Value
Cells(emptyRow, 8).Value = qty6mbox.Value
Cells(emptyRow, 9).Value = qty12mbox.Value
Cells(emptyRow, 11).Value = cutlegnthbox.Value
Cells(emptyRow, 13).Value = tagqtybox.Value
Cells(emptyRow, 15).Value = offcutleftbox.Value
Cells(emptyRow, 17).Value = offcutqtybox.Value
Cells(emptyRow, 19).Value = heatbox.Value

End Sub

Private Sub UserForm_Initialize()

bardialist.AddItem "N10"
bardialist.AddItem "N12"
bardialist.AddItem "N16"
bardialist.AddItem "N20"
bardialist.AddItem "N24"
bardialist.AddItem "N28"
bardialist.AddItem "N32"
bardialist.AddItem "N36+"

'Empty Date
datebox.Value = ""

'Empty Operator
operatorbox.Value = ""

'Empty customer
customerbox.Value = ""

'Empty schedulebox
schedulebox.Value = ""

'Empty Bar Mark
barmarkbox.Value = ""

'Empty Offcut
offcutusedbox.Value = ""

'Empty QTY 6m
qty6mbox.Value = ""

'Empty QTY 12m
qty12mbox.Value = ""

'Empty Cut Legnth
cutlegnthbox.Value = ""

'Empty Tag
tagqtybox.Value = ""

'Empty Offcut left
offcutleftbox.Value = ""

'Empty Offcut QTY
offcutqtybox.Value = ""

'Empty Heat
heatbox.Value = ""

'Set Focus on customer
datebox.SetFocus

End Sub









share|improve this question

























  • See How can I find last row that contains data in the Excel sheet with a macro?

    – Comintern
    Nov 26 '18 at 5:21






  • 2





    Try different method to locate the bottom empty line, such as emptyRow = WorksheetObject.Cells(Rows.Count,"A").End(xlUp).Row

    – PatricK
    Nov 26 '18 at 5:21
















0















I used to play around with VBA years ago and have not had a need for it until now.



Essentially I am just creating a data entry form for our production guys.



What I am trying to make happen is, each time the user clicks ok, it adds data to a new line under the previous one.



I've got it adding a line, but it just keeps overwriting the line with each click of the ok button.



Here is my code



Option Explicit

Private Sub CancelButton_Click()

Unload Me

End Sub

Private Sub ClearButton_Click()

Call UserForm_Initialize

End Sub

Private Sub OKButton_Click()

Dim emptyRow As Long

'Make Shearline active
Shearline.Activate

'Determine emptyRow
emptyRow = WorksheetFunction.CountA(Range("A:A")) + 3

'Transfer information
Cells(emptyRow, 1).Value = datebox.Value
Cells(emptyRow, 2).Value = operatorbox.Value
Cells(emptyRow, 3).Value = customerbox.Value
Cells(emptyRow, 4).Value = schedulebox.Value
Cells(emptyRow, 5).Value = barmarkbox.Value
Cells(emptyRow, 6).Value = bardialist.Value
Cells(emptyRow, 7).Value = offcutusedbox.Value
Cells(emptyRow, 8).Value = qty6mbox.Value
Cells(emptyRow, 9).Value = qty12mbox.Value
Cells(emptyRow, 11).Value = cutlegnthbox.Value
Cells(emptyRow, 13).Value = tagqtybox.Value
Cells(emptyRow, 15).Value = offcutleftbox.Value
Cells(emptyRow, 17).Value = offcutqtybox.Value
Cells(emptyRow, 19).Value = heatbox.Value

End Sub

Private Sub UserForm_Initialize()

bardialist.AddItem "N10"
bardialist.AddItem "N12"
bardialist.AddItem "N16"
bardialist.AddItem "N20"
bardialist.AddItem "N24"
bardialist.AddItem "N28"
bardialist.AddItem "N32"
bardialist.AddItem "N36+"

'Empty Date
datebox.Value = ""

'Empty Operator
operatorbox.Value = ""

'Empty customer
customerbox.Value = ""

'Empty schedulebox
schedulebox.Value = ""

'Empty Bar Mark
barmarkbox.Value = ""

'Empty Offcut
offcutusedbox.Value = ""

'Empty QTY 6m
qty6mbox.Value = ""

'Empty QTY 12m
qty12mbox.Value = ""

'Empty Cut Legnth
cutlegnthbox.Value = ""

'Empty Tag
tagqtybox.Value = ""

'Empty Offcut left
offcutleftbox.Value = ""

'Empty Offcut QTY
offcutqtybox.Value = ""

'Empty Heat
heatbox.Value = ""

'Set Focus on customer
datebox.SetFocus

End Sub









share|improve this question

























  • See How can I find last row that contains data in the Excel sheet with a macro?

    – Comintern
    Nov 26 '18 at 5:21






  • 2





    Try different method to locate the bottom empty line, such as emptyRow = WorksheetObject.Cells(Rows.Count,"A").End(xlUp).Row

    – PatricK
    Nov 26 '18 at 5:21














0












0








0








I used to play around with VBA years ago and have not had a need for it until now.



Essentially I am just creating a data entry form for our production guys.



What I am trying to make happen is, each time the user clicks ok, it adds data to a new line under the previous one.



I've got it adding a line, but it just keeps overwriting the line with each click of the ok button.



Here is my code



Option Explicit

Private Sub CancelButton_Click()

Unload Me

End Sub

Private Sub ClearButton_Click()

Call UserForm_Initialize

End Sub

Private Sub OKButton_Click()

Dim emptyRow As Long

'Make Shearline active
Shearline.Activate

'Determine emptyRow
emptyRow = WorksheetFunction.CountA(Range("A:A")) + 3

'Transfer information
Cells(emptyRow, 1).Value = datebox.Value
Cells(emptyRow, 2).Value = operatorbox.Value
Cells(emptyRow, 3).Value = customerbox.Value
Cells(emptyRow, 4).Value = schedulebox.Value
Cells(emptyRow, 5).Value = barmarkbox.Value
Cells(emptyRow, 6).Value = bardialist.Value
Cells(emptyRow, 7).Value = offcutusedbox.Value
Cells(emptyRow, 8).Value = qty6mbox.Value
Cells(emptyRow, 9).Value = qty12mbox.Value
Cells(emptyRow, 11).Value = cutlegnthbox.Value
Cells(emptyRow, 13).Value = tagqtybox.Value
Cells(emptyRow, 15).Value = offcutleftbox.Value
Cells(emptyRow, 17).Value = offcutqtybox.Value
Cells(emptyRow, 19).Value = heatbox.Value

End Sub

Private Sub UserForm_Initialize()

bardialist.AddItem "N10"
bardialist.AddItem "N12"
bardialist.AddItem "N16"
bardialist.AddItem "N20"
bardialist.AddItem "N24"
bardialist.AddItem "N28"
bardialist.AddItem "N32"
bardialist.AddItem "N36+"

'Empty Date
datebox.Value = ""

'Empty Operator
operatorbox.Value = ""

'Empty customer
customerbox.Value = ""

'Empty schedulebox
schedulebox.Value = ""

'Empty Bar Mark
barmarkbox.Value = ""

'Empty Offcut
offcutusedbox.Value = ""

'Empty QTY 6m
qty6mbox.Value = ""

'Empty QTY 12m
qty12mbox.Value = ""

'Empty Cut Legnth
cutlegnthbox.Value = ""

'Empty Tag
tagqtybox.Value = ""

'Empty Offcut left
offcutleftbox.Value = ""

'Empty Offcut QTY
offcutqtybox.Value = ""

'Empty Heat
heatbox.Value = ""

'Set Focus on customer
datebox.SetFocus

End Sub









share|improve this question
















I used to play around with VBA years ago and have not had a need for it until now.



Essentially I am just creating a data entry form for our production guys.



What I am trying to make happen is, each time the user clicks ok, it adds data to a new line under the previous one.



I've got it adding a line, but it just keeps overwriting the line with each click of the ok button.



Here is my code



Option Explicit

Private Sub CancelButton_Click()

Unload Me

End Sub

Private Sub ClearButton_Click()

Call UserForm_Initialize

End Sub

Private Sub OKButton_Click()

Dim emptyRow As Long

'Make Shearline active
Shearline.Activate

'Determine emptyRow
emptyRow = WorksheetFunction.CountA(Range("A:A")) + 3

'Transfer information
Cells(emptyRow, 1).Value = datebox.Value
Cells(emptyRow, 2).Value = operatorbox.Value
Cells(emptyRow, 3).Value = customerbox.Value
Cells(emptyRow, 4).Value = schedulebox.Value
Cells(emptyRow, 5).Value = barmarkbox.Value
Cells(emptyRow, 6).Value = bardialist.Value
Cells(emptyRow, 7).Value = offcutusedbox.Value
Cells(emptyRow, 8).Value = qty6mbox.Value
Cells(emptyRow, 9).Value = qty12mbox.Value
Cells(emptyRow, 11).Value = cutlegnthbox.Value
Cells(emptyRow, 13).Value = tagqtybox.Value
Cells(emptyRow, 15).Value = offcutleftbox.Value
Cells(emptyRow, 17).Value = offcutqtybox.Value
Cells(emptyRow, 19).Value = heatbox.Value

End Sub

Private Sub UserForm_Initialize()

bardialist.AddItem "N10"
bardialist.AddItem "N12"
bardialist.AddItem "N16"
bardialist.AddItem "N20"
bardialist.AddItem "N24"
bardialist.AddItem "N28"
bardialist.AddItem "N32"
bardialist.AddItem "N36+"

'Empty Date
datebox.Value = ""

'Empty Operator
operatorbox.Value = ""

'Empty customer
customerbox.Value = ""

'Empty schedulebox
schedulebox.Value = ""

'Empty Bar Mark
barmarkbox.Value = ""

'Empty Offcut
offcutusedbox.Value = ""

'Empty QTY 6m
qty6mbox.Value = ""

'Empty QTY 12m
qty12mbox.Value = ""

'Empty Cut Legnth
cutlegnthbox.Value = ""

'Empty Tag
tagqtybox.Value = ""

'Empty Offcut left
offcutleftbox.Value = ""

'Empty Offcut QTY
offcutqtybox.Value = ""

'Empty Heat
heatbox.Value = ""

'Set Focus on customer
datebox.SetFocus

End Sub






excel vba






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 26 '18 at 5:19









Comintern

18.7k42456




18.7k42456










asked Nov 26 '18 at 5:13









JohnJohn

51




51













  • See How can I find last row that contains data in the Excel sheet with a macro?

    – Comintern
    Nov 26 '18 at 5:21






  • 2





    Try different method to locate the bottom empty line, such as emptyRow = WorksheetObject.Cells(Rows.Count,"A").End(xlUp).Row

    – PatricK
    Nov 26 '18 at 5:21



















  • See How can I find last row that contains data in the Excel sheet with a macro?

    – Comintern
    Nov 26 '18 at 5:21






  • 2





    Try different method to locate the bottom empty line, such as emptyRow = WorksheetObject.Cells(Rows.Count,"A").End(xlUp).Row

    – PatricK
    Nov 26 '18 at 5:21

















See How can I find last row that contains data in the Excel sheet with a macro?

– Comintern
Nov 26 '18 at 5:21





See How can I find last row that contains data in the Excel sheet with a macro?

– Comintern
Nov 26 '18 at 5:21




2




2





Try different method to locate the bottom empty line, such as emptyRow = WorksheetObject.Cells(Rows.Count,"A").End(xlUp).Row

– PatricK
Nov 26 '18 at 5:21





Try different method to locate the bottom empty line, such as emptyRow = WorksheetObject.Cells(Rows.Count,"A").End(xlUp).Row

– PatricK
Nov 26 '18 at 5:21












1 Answer
1






active

oldest

votes


















-2














Close, you need to find the last row..



substitute this



'Determine emptyRow
emptyRow = WorksheetFunction.CountA(Range("A:A")) + 3


For this



'Determine emptyRow
emptyRow = Sheets("sheet name here").Range("A" & Rows.Count).End(xlUp).Row + 1


Change sheet name here to your actual sheet name. Make sure you keep the "



The reason for the +1 is that the last row code gets the last used cell in that col. as you want the next cell which is blank, we +1



To add, we usually call the formula above LastRow or similar.. If you do any searching this is how it will normally show up



However the better way to do this and safe proof for future is to set your sheets and workbook.



Thus:



DIM wb As Workbook
DIM wks As Worksheet

Set wb As ThisWorkbook
Set wks As wb.Sheets("add sheet name")

'Determine emptyRow
emptyRow = wks.Range("A" & Rows.Count).End(xlUp).Row + 1





share|improve this answer





















  • 1





    Your Rows.Count is unqualified

    – JohnyL
    Nov 26 '18 at 5:54











  • @JohnyL I tested it and it works. Suggest retrying and possibly debug.print emptyRow to confirm

    – alowflyingpig
    Nov 26 '18 at 6:02






  • 2





    @alowflyingpig what JohnyL is trying to point out is that it might work today, but may fail in the future when the ActiveSheet is changed while the macro is running. This could easily occur when you have more than one workbook open and multiple macros/events are running. Fully qualifying all ranges protects against this.

    – AJD
    Nov 26 '18 at 6:12











  • @AJD that is exactly what I'd do also.. I'm not here to re-write the OP's code, but to lend a hand to help make it work. My answer will do that. To satisfy the correct way of doing it I will write a new answer :)

    – alowflyingpig
    Nov 26 '18 at 6:16











  • down voting for a correct answer? yikes...

    – alowflyingpig
    Nov 26 '18 at 6:46











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',
autoActivateHeartbeat: false,
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
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53475081%2fhaving-issues-with-vba-adding-a-new-line-for-each-entry%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









-2














Close, you need to find the last row..



substitute this



'Determine emptyRow
emptyRow = WorksheetFunction.CountA(Range("A:A")) + 3


For this



'Determine emptyRow
emptyRow = Sheets("sheet name here").Range("A" & Rows.Count).End(xlUp).Row + 1


Change sheet name here to your actual sheet name. Make sure you keep the "



The reason for the +1 is that the last row code gets the last used cell in that col. as you want the next cell which is blank, we +1



To add, we usually call the formula above LastRow or similar.. If you do any searching this is how it will normally show up



However the better way to do this and safe proof for future is to set your sheets and workbook.



Thus:



DIM wb As Workbook
DIM wks As Worksheet

Set wb As ThisWorkbook
Set wks As wb.Sheets("add sheet name")

'Determine emptyRow
emptyRow = wks.Range("A" & Rows.Count).End(xlUp).Row + 1





share|improve this answer





















  • 1





    Your Rows.Count is unqualified

    – JohnyL
    Nov 26 '18 at 5:54











  • @JohnyL I tested it and it works. Suggest retrying and possibly debug.print emptyRow to confirm

    – alowflyingpig
    Nov 26 '18 at 6:02






  • 2





    @alowflyingpig what JohnyL is trying to point out is that it might work today, but may fail in the future when the ActiveSheet is changed while the macro is running. This could easily occur when you have more than one workbook open and multiple macros/events are running. Fully qualifying all ranges protects against this.

    – AJD
    Nov 26 '18 at 6:12











  • @AJD that is exactly what I'd do also.. I'm not here to re-write the OP's code, but to lend a hand to help make it work. My answer will do that. To satisfy the correct way of doing it I will write a new answer :)

    – alowflyingpig
    Nov 26 '18 at 6:16











  • down voting for a correct answer? yikes...

    – alowflyingpig
    Nov 26 '18 at 6:46
















-2














Close, you need to find the last row..



substitute this



'Determine emptyRow
emptyRow = WorksheetFunction.CountA(Range("A:A")) + 3


For this



'Determine emptyRow
emptyRow = Sheets("sheet name here").Range("A" & Rows.Count).End(xlUp).Row + 1


Change sheet name here to your actual sheet name. Make sure you keep the "



The reason for the +1 is that the last row code gets the last used cell in that col. as you want the next cell which is blank, we +1



To add, we usually call the formula above LastRow or similar.. If you do any searching this is how it will normally show up



However the better way to do this and safe proof for future is to set your sheets and workbook.



Thus:



DIM wb As Workbook
DIM wks As Worksheet

Set wb As ThisWorkbook
Set wks As wb.Sheets("add sheet name")

'Determine emptyRow
emptyRow = wks.Range("A" & Rows.Count).End(xlUp).Row + 1





share|improve this answer





















  • 1





    Your Rows.Count is unqualified

    – JohnyL
    Nov 26 '18 at 5:54











  • @JohnyL I tested it and it works. Suggest retrying and possibly debug.print emptyRow to confirm

    – alowflyingpig
    Nov 26 '18 at 6:02






  • 2





    @alowflyingpig what JohnyL is trying to point out is that it might work today, but may fail in the future when the ActiveSheet is changed while the macro is running. This could easily occur when you have more than one workbook open and multiple macros/events are running. Fully qualifying all ranges protects against this.

    – AJD
    Nov 26 '18 at 6:12











  • @AJD that is exactly what I'd do also.. I'm not here to re-write the OP's code, but to lend a hand to help make it work. My answer will do that. To satisfy the correct way of doing it I will write a new answer :)

    – alowflyingpig
    Nov 26 '18 at 6:16











  • down voting for a correct answer? yikes...

    – alowflyingpig
    Nov 26 '18 at 6:46














-2












-2








-2







Close, you need to find the last row..



substitute this



'Determine emptyRow
emptyRow = WorksheetFunction.CountA(Range("A:A")) + 3


For this



'Determine emptyRow
emptyRow = Sheets("sheet name here").Range("A" & Rows.Count).End(xlUp).Row + 1


Change sheet name here to your actual sheet name. Make sure you keep the "



The reason for the +1 is that the last row code gets the last used cell in that col. as you want the next cell which is blank, we +1



To add, we usually call the formula above LastRow or similar.. If you do any searching this is how it will normally show up



However the better way to do this and safe proof for future is to set your sheets and workbook.



Thus:



DIM wb As Workbook
DIM wks As Worksheet

Set wb As ThisWorkbook
Set wks As wb.Sheets("add sheet name")

'Determine emptyRow
emptyRow = wks.Range("A" & Rows.Count).End(xlUp).Row + 1





share|improve this answer















Close, you need to find the last row..



substitute this



'Determine emptyRow
emptyRow = WorksheetFunction.CountA(Range("A:A")) + 3


For this



'Determine emptyRow
emptyRow = Sheets("sheet name here").Range("A" & Rows.Count).End(xlUp).Row + 1


Change sheet name here to your actual sheet name. Make sure you keep the "



The reason for the +1 is that the last row code gets the last used cell in that col. as you want the next cell which is blank, we +1



To add, we usually call the formula above LastRow or similar.. If you do any searching this is how it will normally show up



However the better way to do this and safe proof for future is to set your sheets and workbook.



Thus:



DIM wb As Workbook
DIM wks As Worksheet

Set wb As ThisWorkbook
Set wks As wb.Sheets("add sheet name")

'Determine emptyRow
emptyRow = wks.Range("A" & Rows.Count).End(xlUp).Row + 1






share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 26 '18 at 6:20

























answered Nov 26 '18 at 5:30









alowflyingpigalowflyingpig

1959




1959








  • 1





    Your Rows.Count is unqualified

    – JohnyL
    Nov 26 '18 at 5:54











  • @JohnyL I tested it and it works. Suggest retrying and possibly debug.print emptyRow to confirm

    – alowflyingpig
    Nov 26 '18 at 6:02






  • 2





    @alowflyingpig what JohnyL is trying to point out is that it might work today, but may fail in the future when the ActiveSheet is changed while the macro is running. This could easily occur when you have more than one workbook open and multiple macros/events are running. Fully qualifying all ranges protects against this.

    – AJD
    Nov 26 '18 at 6:12











  • @AJD that is exactly what I'd do also.. I'm not here to re-write the OP's code, but to lend a hand to help make it work. My answer will do that. To satisfy the correct way of doing it I will write a new answer :)

    – alowflyingpig
    Nov 26 '18 at 6:16











  • down voting for a correct answer? yikes...

    – alowflyingpig
    Nov 26 '18 at 6:46














  • 1





    Your Rows.Count is unqualified

    – JohnyL
    Nov 26 '18 at 5:54











  • @JohnyL I tested it and it works. Suggest retrying and possibly debug.print emptyRow to confirm

    – alowflyingpig
    Nov 26 '18 at 6:02






  • 2





    @alowflyingpig what JohnyL is trying to point out is that it might work today, but may fail in the future when the ActiveSheet is changed while the macro is running. This could easily occur when you have more than one workbook open and multiple macros/events are running. Fully qualifying all ranges protects against this.

    – AJD
    Nov 26 '18 at 6:12











  • @AJD that is exactly what I'd do also.. I'm not here to re-write the OP's code, but to lend a hand to help make it work. My answer will do that. To satisfy the correct way of doing it I will write a new answer :)

    – alowflyingpig
    Nov 26 '18 at 6:16











  • down voting for a correct answer? yikes...

    – alowflyingpig
    Nov 26 '18 at 6:46








1




1





Your Rows.Count is unqualified

– JohnyL
Nov 26 '18 at 5:54





Your Rows.Count is unqualified

– JohnyL
Nov 26 '18 at 5:54













@JohnyL I tested it and it works. Suggest retrying and possibly debug.print emptyRow to confirm

– alowflyingpig
Nov 26 '18 at 6:02





@JohnyL I tested it and it works. Suggest retrying and possibly debug.print emptyRow to confirm

– alowflyingpig
Nov 26 '18 at 6:02




2




2





@alowflyingpig what JohnyL is trying to point out is that it might work today, but may fail in the future when the ActiveSheet is changed while the macro is running. This could easily occur when you have more than one workbook open and multiple macros/events are running. Fully qualifying all ranges protects against this.

– AJD
Nov 26 '18 at 6:12





@alowflyingpig what JohnyL is trying to point out is that it might work today, but may fail in the future when the ActiveSheet is changed while the macro is running. This could easily occur when you have more than one workbook open and multiple macros/events are running. Fully qualifying all ranges protects against this.

– AJD
Nov 26 '18 at 6:12













@AJD that is exactly what I'd do also.. I'm not here to re-write the OP's code, but to lend a hand to help make it work. My answer will do that. To satisfy the correct way of doing it I will write a new answer :)

– alowflyingpig
Nov 26 '18 at 6:16





@AJD that is exactly what I'd do also.. I'm not here to re-write the OP's code, but to lend a hand to help make it work. My answer will do that. To satisfy the correct way of doing it I will write a new answer :)

– alowflyingpig
Nov 26 '18 at 6:16













down voting for a correct answer? yikes...

– alowflyingpig
Nov 26 '18 at 6:46





down voting for a correct answer? yikes...

– alowflyingpig
Nov 26 '18 at 6:46


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53475081%2fhaving-issues-with-vba-adding-a-new-line-for-each-entry%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

Contact image not getting when fetch all contact list from iPhone by CNContact

count number of partitions of a set with n elements into k subsets

A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks