Macro not working properly

msumith

New Member
Joined
May 25, 2011
Messages
2
Hi Mr. Excel,

I was using your book "Excel 2010 VBA and Macros" in which I was in 1st Chapter where I am trying to import a file invoice.txt using the macro I am recording.

I am not seeing the code which is importing but all others are fine.

I am only able to see the following code, can you help me why the code for importing the file is not being recorded.

Sub ImportInvoice()
'
' ImportInvoice Macro
' Does import of file
'
' Keyboard Shortcut: Ctrl+i
'
Selection.End(xlDown).Select
Selection.End(xlDown).Select
Selection.End(xlUp).Select
Range("A20").Select
ActiveCell.FormulaR1C1 = "Total"
Range("D20").Select
ActiveWindow.SmallScroll Down:=-21
Range("E20").Select
ActiveCell.FormulaR1C1 = "=SUM(R[-18]C:R[-1]C)"
Range("E20").Select
Selection.Copy
Range("F20:G20").Select
Application.CutCopyMode = False
Range("E20").Select
Selection.AutoFill Destination:=Range("E20:G20"), Type:=xlFillDefault
Range("E20:G20").Select
Rows("1:1").Select
Selection.Font.Bold = True
Rows("20:20").Select
Selection.Font.Bold = True
Cells.Select
Range("H11").Activate
Selection.Columns.AutoFit
Range("L18").Select
End Sub
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
In the VBA editor, on the right-side of the screen is the Project-VBAProject pane (Ctrl+r to view it if not visible).

In the VBAProject window you should have a tree view with Module1 and maybe Module2 at the bottom. Your recorded macro code is probably in Module1 or in Module2. Double click on them to view.
 
Upvote 0
Hi I am using the Excel 2010 and I am able to see only one Module.

The problem is that the entire code is not visible only a part of the code is present and it is working partially.

The import of file is not showing but the rest of the commands are present. So when I run the macro is it only doing the formatting and calculation but not the import of the file.

Workbooks.OpenText Filename:= _
“C:\invoice.txt”, Origin:=437, StartRow:=1, DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, _
Tab:=True, Semicolon:=False, Comma:=True, Space:=False, _
Other:=False, FieldInfo:=Array(Array(1, 3), Array(2, 1), Array(3, 1), _
Array(4, 1), Array(5, 1), Array(6, 1), Array(7, 1)), _​
TrailingMinusNumbers:=True


 
Upvote 0

Forum statistics

Threads
1,224,502
Messages
6,179,126
Members
452,890
Latest member
Nikhil Ramesh

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