Here is my issue, I have some code in the macro and now i have added the msgbox. so when i run this macro it just shows the msg box and runs the macro as usual. but what i need is after i run the macro it should show the msgbox and it should open the macro though the vba and after i change some thing it should run again.
I have to do some changes in the excel daily, so the files i extract daily have a certain date like 1 sep 2008, 2 sep 2008. so i import these files and do some coulmn and row changes and rename the sheets accordingly like a 1 sep 2008 to sheet 1, b 1 sep 2008 to sheet 2 and so on. and then i save th e whole wook book as all 1 sep 2008. so the file import and the sheets and the whole work book has the same name.
so what i did is when creating a marco i took a single file and did all the changes in it and saved the macro.
so for my case if i need to do the same for sep 2 2008 i first need to open the macro change the file name to 2 sep 2008 save the macro and run the macro. which is waste of time as i need to do this on a daily basis.
can some one help me how can i do this in a easier way.
As i have mentioned in the previous message i have the option of changing the date manually, but as this needs to done daily so i want to omit this and do some this automatic. like when i run the macro it pops a promt asking for certain date and it replaces the dates in the macro and then the macro runs accordingly for that date.
And please dont send those tips on how to post a question.
I am not stuck, the marco i did runs but the problem is on how to run the marco for daily. i need to change the date every day. so some thing like a prompt asking for a certain date would help.
please see the code below.
Sub t()
'
MsgBox "Please change the dates 10 times (6 times for the original report file, 3 times for sheets and 1 time for the actual work book file"
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;C:\..\S_07Oct2008.csv" _
, Destination:=Range("A1"))
.Name = "S_07Oct2008"
\
\
code to change from .csv to .xsl
\
\
End With
Columns("B:F").Select
Selection.ClearContents
Columns("G:Z").Select
Selection.Cut Destination:=Columns("B:U")
Range("A1").Select
Sheets("Sheet1").Select
Sheets("Sheet1").Name = "S Oct 1 2008"
Sheets("Sheet2").Select
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;C:\..S_07Oct2008.csv" _
, Destination:=Range("A1"))
.Name = "b_S_07Oct2008"
\
\
code to change from .csv to .xsl
\
\
End With
Columns("C:C").Select
Selection.ClearContents
Columns("D:Z").Select
Selection.Cut Destination:=Columns("C:Y")
Range("A1").Select
Sheets("Sheet2").Select
Sheets("Sheet2").Name = "B Oct 1 2008"
Sheets("Sheet3").Select
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;C:\..\u_S_07Oct2008.csv" _
, Destination:=Range("A1"))
.Name = "u_S_07Oct2008"
\
\
code to change from .csv to .xsl
\
\
End With
Columns("G:G").Select
Selection.ClearContents
Columns("H:Z").Select
Selection.Cut Destination:=Columns("G:Y")
Columns("G:Y").Select
Range("A1").Select
Range("A110000").Sort Key1:=Range("D2"), Order1:=xlAscending, Key2:=Range _
("B2"), Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1, MatchCase _
:=False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, _
DataOption2:=xlSortNormal
Selection.EntireColumn.Insert
Columns("E:E").Select
Selection.Cut Destination:=Columns("A:A")
Columns("F:Y").Select
Selection.Cut Destination:=Columns("E:X")
Columns("E:X").Select
Range("A1").Select
Sheets("Sheet3").Select
Sheets("Sheet3").Name = "U Oct 1 2008"
Range("A1").Select
ChDir _
"C:\..\A p"
ActiveWorkbook.SaveAs Filename:= _
"C:\..\A p\ACA S October 01 2008.xls" _
, FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
End Sub
Above is the code.
I have included the msgbox which says i need to change the date 10 times.
but when i click the ok button in the msgbox, it still runs the macro. what i need it a promt which asks to change the date and it replaces 10 times in the macro and runs it accordigly to that date.
but see i want to replace the date i give in the input field with the ones i have in the macro(see above i.e i nee d to change the date 10 times) so that it will run the macro for that date and saves the whole workbook for that date.
if i add the code u gave it asks for the input date(with default date -- (today's date -1)) then it replaces the date i enter in the A1 and then displays the msg box i have in the above code and then it is running the macro as usual and it is showing the date in the sheet 1 (that is now renamed to s 1 oct 2008) but not in A1 but at last as bcoz its due to the macro steps.
please see the above code so that u will get my point.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.