importing data to vba

moosa77

New Member
Joined
Jun 11, 2024
Messages
4
Office Version
  1. 2021
Platform
  1. Windows
  2. MacOS
  3. Web
hi

as you can see below i imported my monthly update started in Nov 2007 , how i can make the next months in sequence in easy way?

Sub IMPORT_DATA()
'
' IMPORT_DATA Macro
'



Workbooks.OpenText Filename:= _
monkey, Origin:=xlMSDOS _
, StartRow:=4, DataType:=xlFixedWidth, FieldInfo:=Array(Array(0, 1), Array( _
11, 1), Array(23, 1), Array(28, 1), Array(43, 1), Array(53, 1)), TrailingMinusNumbers _
:=True
Sheets("Nov2007").Select
ActiveSheet.Move Before:=Workbooks("MONTHLY UPDATE.xlsm").Sheets(1)
Rows("2:2").Select
Selection.Delete Shift:=xlUp
Range("A1").Selec
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Sequence how, exactly?

Are you just wanting to dynamically get the name of the sheet you need, i.e. "Jun2024" for this month instead of "Nov2007"?

If so, you can get by replacing this:
VBA Code:
Sheets("Nov2007").Select
with this:
VBA Code:
    Dim curMnth As String
    curMnth = Format(Date, "mmmyyyy")
    Sheets(curMnth).Select
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,183
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top