Count rows and export based on criteria










1















So I have an Excel file, that I want to export some of the rows to another Excel file, my problem is that I have a row that is like:



1 
1
1
2
2
2
3
3
3
1
1
1


And I want to export from the first row with number one to the last row with number 3, and after exportation delete that same lines.



So far i have this.



Private Sub export2()
folha = exportform.Label14.Caption
On Error GoTo ErrHandler
Application.ScreenUpdating = False


Dim src As Workbook

' ABRIR EXCEL
Set src = Workbooks.Open("U:MecânicaProduçãoOEEOEE ( FULL LOG )FRSFRS_DADOS.xlsx", True, False)
WS_Count = src.Worksheets.Count
For o = 1 To WS_Count
src.Worksheets(o).Unprotect password:="registoOEE"
Next o

lastsrc = src.Worksheets("DADOS").Range("A65536").End(xlUp).Row
last = Application.ThisWorkbook.Worksheets(folha).Range("A65536").End(xlUp).Row




Dim last, I As Integer
Dim turno As String

Sheets(folha).Select

For I = 2 To last
'If application.ThisWorkbook.Worksheets(folha).Cells(last, 61)














Next I




ErrHandler:
Application.EnableEvents = True
Application.ScreenUpdating = True







For o = 1 To WS_Count
src.Worksheets(o).Protect password:="registoOEE"
Next o


Application.DisplayAlerts = False 'IT WORKS TO DISABLE ALERT PROMPT

'SAVES FILE USING THE VARIABLE BOOKNAME AS FILENAME
src.Save

Application.DisplayAlerts = True 'RESETS DISPLAY ALERTS

' CLOSE THE SOURCE FILE.
src.Close True ' FALSE - DON'T SAVE THE SOURCE FILE.
Set src = Nothing


fim:
End Sub


I've edited so you can see what code i have already, hope it helps.










share|improve this question



















  • 1





    Please add the code you already have and explain in a detailed way where you are stuck. This will allow us to provide a decent answer. Regards,

    – Lambik
    Nov 14 '18 at 8:41











  • I have only the code to open the other excel file , after that i'm missing all the code that i need to do what i want

    – nagileica
    Nov 14 '18 at 9:03











  • People will be willing to help if you could show that you have researched and tried yourself. Look up "last row" to begin with.. look up "delete rows".. do some research, post your code and we can go from there.

    – alowflyingpig
    Nov 14 '18 at 9:16












  • Ok , i've edited the post and pasted the code that i have in right now, hope it helps.

    – nagileica
    Nov 14 '18 at 10:13















1















So I have an Excel file, that I want to export some of the rows to another Excel file, my problem is that I have a row that is like:



1 
1
1
2
2
2
3
3
3
1
1
1


And I want to export from the first row with number one to the last row with number 3, and after exportation delete that same lines.



So far i have this.



Private Sub export2()
folha = exportform.Label14.Caption
On Error GoTo ErrHandler
Application.ScreenUpdating = False


Dim src As Workbook

' ABRIR EXCEL
Set src = Workbooks.Open("U:MecânicaProduçãoOEEOEE ( FULL LOG )FRSFRS_DADOS.xlsx", True, False)
WS_Count = src.Worksheets.Count
For o = 1 To WS_Count
src.Worksheets(o).Unprotect password:="registoOEE"
Next o

lastsrc = src.Worksheets("DADOS").Range("A65536").End(xlUp).Row
last = Application.ThisWorkbook.Worksheets(folha).Range("A65536").End(xlUp).Row




Dim last, I As Integer
Dim turno As String

Sheets(folha).Select

For I = 2 To last
'If application.ThisWorkbook.Worksheets(folha).Cells(last, 61)














Next I




ErrHandler:
Application.EnableEvents = True
Application.ScreenUpdating = True







For o = 1 To WS_Count
src.Worksheets(o).Protect password:="registoOEE"
Next o


Application.DisplayAlerts = False 'IT WORKS TO DISABLE ALERT PROMPT

'SAVES FILE USING THE VARIABLE BOOKNAME AS FILENAME
src.Save

Application.DisplayAlerts = True 'RESETS DISPLAY ALERTS

' CLOSE THE SOURCE FILE.
src.Close True ' FALSE - DON'T SAVE THE SOURCE FILE.
Set src = Nothing


fim:
End Sub


I've edited so you can see what code i have already, hope it helps.










share|improve this question



















  • 1





    Please add the code you already have and explain in a detailed way where you are stuck. This will allow us to provide a decent answer. Regards,

    – Lambik
    Nov 14 '18 at 8:41











  • I have only the code to open the other excel file , after that i'm missing all the code that i need to do what i want

    – nagileica
    Nov 14 '18 at 9:03











  • People will be willing to help if you could show that you have researched and tried yourself. Look up "last row" to begin with.. look up "delete rows".. do some research, post your code and we can go from there.

    – alowflyingpig
    Nov 14 '18 at 9:16












  • Ok , i've edited the post and pasted the code that i have in right now, hope it helps.

    – nagileica
    Nov 14 '18 at 10:13













1












1








1








So I have an Excel file, that I want to export some of the rows to another Excel file, my problem is that I have a row that is like:



1 
1
1
2
2
2
3
3
3
1
1
1


And I want to export from the first row with number one to the last row with number 3, and after exportation delete that same lines.



So far i have this.



Private Sub export2()
folha = exportform.Label14.Caption
On Error GoTo ErrHandler
Application.ScreenUpdating = False


Dim src As Workbook

' ABRIR EXCEL
Set src = Workbooks.Open("U:MecânicaProduçãoOEEOEE ( FULL LOG )FRSFRS_DADOS.xlsx", True, False)
WS_Count = src.Worksheets.Count
For o = 1 To WS_Count
src.Worksheets(o).Unprotect password:="registoOEE"
Next o

lastsrc = src.Worksheets("DADOS").Range("A65536").End(xlUp).Row
last = Application.ThisWorkbook.Worksheets(folha).Range("A65536").End(xlUp).Row




Dim last, I As Integer
Dim turno As String

Sheets(folha).Select

For I = 2 To last
'If application.ThisWorkbook.Worksheets(folha).Cells(last, 61)














Next I




ErrHandler:
Application.EnableEvents = True
Application.ScreenUpdating = True







For o = 1 To WS_Count
src.Worksheets(o).Protect password:="registoOEE"
Next o


Application.DisplayAlerts = False 'IT WORKS TO DISABLE ALERT PROMPT

'SAVES FILE USING THE VARIABLE BOOKNAME AS FILENAME
src.Save

Application.DisplayAlerts = True 'RESETS DISPLAY ALERTS

' CLOSE THE SOURCE FILE.
src.Close True ' FALSE - DON'T SAVE THE SOURCE FILE.
Set src = Nothing


fim:
End Sub


I've edited so you can see what code i have already, hope it helps.










share|improve this question
















So I have an Excel file, that I want to export some of the rows to another Excel file, my problem is that I have a row that is like:



1 
1
1
2
2
2
3
3
3
1
1
1


And I want to export from the first row with number one to the last row with number 3, and after exportation delete that same lines.



So far i have this.



Private Sub export2()
folha = exportform.Label14.Caption
On Error GoTo ErrHandler
Application.ScreenUpdating = False


Dim src As Workbook

' ABRIR EXCEL
Set src = Workbooks.Open("U:MecânicaProduçãoOEEOEE ( FULL LOG )FRSFRS_DADOS.xlsx", True, False)
WS_Count = src.Worksheets.Count
For o = 1 To WS_Count
src.Worksheets(o).Unprotect password:="registoOEE"
Next o

lastsrc = src.Worksheets("DADOS").Range("A65536").End(xlUp).Row
last = Application.ThisWorkbook.Worksheets(folha).Range("A65536").End(xlUp).Row




Dim last, I As Integer
Dim turno As String

Sheets(folha).Select

For I = 2 To last
'If application.ThisWorkbook.Worksheets(folha).Cells(last, 61)














Next I




ErrHandler:
Application.EnableEvents = True
Application.ScreenUpdating = True







For o = 1 To WS_Count
src.Worksheets(o).Protect password:="registoOEE"
Next o


Application.DisplayAlerts = False 'IT WORKS TO DISABLE ALERT PROMPT

'SAVES FILE USING THE VARIABLE BOOKNAME AS FILENAME
src.Save

Application.DisplayAlerts = True 'RESETS DISPLAY ALERTS

' CLOSE THE SOURCE FILE.
src.Close True ' FALSE - DON'T SAVE THE SOURCE FILE.
Set src = Nothing


fim:
End Sub


I've edited so you can see what code i have already, hope it helps.







excel vba excel-formula excel-2010






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 14 '18 at 10:12







nagileica

















asked Nov 14 '18 at 8:00









nagileicanagileica

134




134







  • 1





    Please add the code you already have and explain in a detailed way where you are stuck. This will allow us to provide a decent answer. Regards,

    – Lambik
    Nov 14 '18 at 8:41











  • I have only the code to open the other excel file , after that i'm missing all the code that i need to do what i want

    – nagileica
    Nov 14 '18 at 9:03











  • People will be willing to help if you could show that you have researched and tried yourself. Look up "last row" to begin with.. look up "delete rows".. do some research, post your code and we can go from there.

    – alowflyingpig
    Nov 14 '18 at 9:16












  • Ok , i've edited the post and pasted the code that i have in right now, hope it helps.

    – nagileica
    Nov 14 '18 at 10:13












  • 1





    Please add the code you already have and explain in a detailed way where you are stuck. This will allow us to provide a decent answer. Regards,

    – Lambik
    Nov 14 '18 at 8:41











  • I have only the code to open the other excel file , after that i'm missing all the code that i need to do what i want

    – nagileica
    Nov 14 '18 at 9:03











  • People will be willing to help if you could show that you have researched and tried yourself. Look up "last row" to begin with.. look up "delete rows".. do some research, post your code and we can go from there.

    – alowflyingpig
    Nov 14 '18 at 9:16












  • Ok , i've edited the post and pasted the code that i have in right now, hope it helps.

    – nagileica
    Nov 14 '18 at 10:13







1




1





Please add the code you already have and explain in a detailed way where you are stuck. This will allow us to provide a decent answer. Regards,

– Lambik
Nov 14 '18 at 8:41





Please add the code you already have and explain in a detailed way where you are stuck. This will allow us to provide a decent answer. Regards,

– Lambik
Nov 14 '18 at 8:41













I have only the code to open the other excel file , after that i'm missing all the code that i need to do what i want

– nagileica
Nov 14 '18 at 9:03





I have only the code to open the other excel file , after that i'm missing all the code that i need to do what i want

– nagileica
Nov 14 '18 at 9:03













People will be willing to help if you could show that you have researched and tried yourself. Look up "last row" to begin with.. look up "delete rows".. do some research, post your code and we can go from there.

– alowflyingpig
Nov 14 '18 at 9:16






People will be willing to help if you could show that you have researched and tried yourself. Look up "last row" to begin with.. look up "delete rows".. do some research, post your code and we can go from there.

– alowflyingpig
Nov 14 '18 at 9:16














Ok , i've edited the post and pasted the code that i have in right now, hope it helps.

– nagileica
Nov 14 '18 at 10:13





Ok , i've edited the post and pasted the code that i have in right now, hope it helps.

– nagileica
Nov 14 '18 at 10:13












0






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',
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%2f53295450%2fcount-rows-and-export-based-on-criteria%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















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%2f53295450%2fcount-rows-and-export-based-on-criteria%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







這個網誌中的熱門文章

Barbados

How to read a connectionString WITH PROVIDER in .NET Core?

Node.js Script on GitHub Pages or Amazon S3