Excel VBA 2 inputs files each opend and copied with diffrent format instead of same











up vote
0
down vote

favorite












I have some reports downloaded from SAP as .xls (in same structure and format cells). I have macro which open each file a copy it to one "data" sheet. One file is copied correctly value "1" in cell with format "General" is copied and paste as "1" but values from other input files are opened, copied and paste as 10000000. I don't know why. Any suggestons? Thanks for your help.



Sub open_copy_data()

Workbooks.Open FileName:=macro_link & "" & file_name
Sheets(1).Copy After:=Workbooks(macro_name).Sheets(Workbooks(macro_name).Sheets.Count)
ActiveSheet.Name = Application.WorksheetFunction.Substitute(Left(file_name, 31), ".xlsx", "")
Workbooks(file_name).Close

End Sub









share|improve this question
























  • Open each SAP .xls file and check contents and format. If they are OK, then step through your code with the debugger and check the sheets in each step.
    – Paul Ogilvie
    Nov 8 at 13:53










  • I have found out that when all the files are open by duoble click, all values are corecct. When is the broken file is open throught file -> open, the wizard has determined that my data is Delimited. I tiried to add to my code: Format:=1 (and other options), but put all values to one cell and the second one has zero numbers only. How can I fix this?
    – Witchery
    Nov 8 at 15:04















up vote
0
down vote

favorite












I have some reports downloaded from SAP as .xls (in same structure and format cells). I have macro which open each file a copy it to one "data" sheet. One file is copied correctly value "1" in cell with format "General" is copied and paste as "1" but values from other input files are opened, copied and paste as 10000000. I don't know why. Any suggestons? Thanks for your help.



Sub open_copy_data()

Workbooks.Open FileName:=macro_link & "" & file_name
Sheets(1).Copy After:=Workbooks(macro_name).Sheets(Workbooks(macro_name).Sheets.Count)
ActiveSheet.Name = Application.WorksheetFunction.Substitute(Left(file_name, 31), ".xlsx", "")
Workbooks(file_name).Close

End Sub









share|improve this question
























  • Open each SAP .xls file and check contents and format. If they are OK, then step through your code with the debugger and check the sheets in each step.
    – Paul Ogilvie
    Nov 8 at 13:53










  • I have found out that when all the files are open by duoble click, all values are corecct. When is the broken file is open throught file -> open, the wizard has determined that my data is Delimited. I tiried to add to my code: Format:=1 (and other options), but put all values to one cell and the second one has zero numbers only. How can I fix this?
    – Witchery
    Nov 8 at 15:04













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I have some reports downloaded from SAP as .xls (in same structure and format cells). I have macro which open each file a copy it to one "data" sheet. One file is copied correctly value "1" in cell with format "General" is copied and paste as "1" but values from other input files are opened, copied and paste as 10000000. I don't know why. Any suggestons? Thanks for your help.



Sub open_copy_data()

Workbooks.Open FileName:=macro_link & "" & file_name
Sheets(1).Copy After:=Workbooks(macro_name).Sheets(Workbooks(macro_name).Sheets.Count)
ActiveSheet.Name = Application.WorksheetFunction.Substitute(Left(file_name, 31), ".xlsx", "")
Workbooks(file_name).Close

End Sub









share|improve this question















I have some reports downloaded from SAP as .xls (in same structure and format cells). I have macro which open each file a copy it to one "data" sheet. One file is copied correctly value "1" in cell with format "General" is copied and paste as "1" but values from other input files are opened, copied and paste as 10000000. I don't know why. Any suggestons? Thanks for your help.



Sub open_copy_data()

Workbooks.Open FileName:=macro_link & "" & file_name
Sheets(1).Copy After:=Workbooks(macro_name).Sheets(Workbooks(macro_name).Sheets.Count)
ActiveSheet.Name = Application.WorksheetFunction.Substitute(Left(file_name, 31), ".xlsx", "")
Workbooks(file_name).Close

End Sub






excel vba






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 8 at 16:09









Cindy Meister

13.2k101934




13.2k101934










asked Nov 8 at 12:55









Witchery

64




64












  • Open each SAP .xls file and check contents and format. If they are OK, then step through your code with the debugger and check the sheets in each step.
    – Paul Ogilvie
    Nov 8 at 13:53










  • I have found out that when all the files are open by duoble click, all values are corecct. When is the broken file is open throught file -> open, the wizard has determined that my data is Delimited. I tiried to add to my code: Format:=1 (and other options), but put all values to one cell and the second one has zero numbers only. How can I fix this?
    – Witchery
    Nov 8 at 15:04


















  • Open each SAP .xls file and check contents and format. If they are OK, then step through your code with the debugger and check the sheets in each step.
    – Paul Ogilvie
    Nov 8 at 13:53










  • I have found out that when all the files are open by duoble click, all values are corecct. When is the broken file is open throught file -> open, the wizard has determined that my data is Delimited. I tiried to add to my code: Format:=1 (and other options), but put all values to one cell and the second one has zero numbers only. How can I fix this?
    – Witchery
    Nov 8 at 15:04
















Open each SAP .xls file and check contents and format. If they are OK, then step through your code with the debugger and check the sheets in each step.
– Paul Ogilvie
Nov 8 at 13:53




Open each SAP .xls file and check contents and format. If they are OK, then step through your code with the debugger and check the sheets in each step.
– Paul Ogilvie
Nov 8 at 13:53












I have found out that when all the files are open by duoble click, all values are corecct. When is the broken file is open throught file -> open, the wizard has determined that my data is Delimited. I tiried to add to my code: Format:=1 (and other options), but put all values to one cell and the second one has zero numbers only. How can I fix this?
– Witchery
Nov 8 at 15:04




I have found out that when all the files are open by duoble click, all values are corecct. When is the broken file is open throught file -> open, the wizard has determined that my data is Delimited. I tiried to add to my code: Format:=1 (and other options), but put all values to one cell and the second one has zero numbers only. How can I fix this?
– Witchery
Nov 8 at 15:04

















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
});


}
});














 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53208197%2fexcel-vba-2-inputs-files-each-opend-and-copied-with-diffrent-format-instead-of-s%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53208197%2fexcel-vba-2-inputs-files-each-opend-and-copied-with-diffrent-format-instead-of-s%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

Landwehr

Reims

Javascript gets undefined on array