![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: Mar 2002
Posts: 11
|
Hi, got a malfuntioning(??) VBA code.. After loading some exported text file, I want to add headers to it. Recorded inserting a row at the top, and typing the names. But after runnung the macro, the first data row is replaced by the header. What's wrong with this code?? Appreciate any help rendered..
Cheers Set xlApp = CreateObject("Excel.Application") xlApp.Visible = True xlApp.Workbooks.OpenText Filename:=strTargetStep2, Origin:=xlWindows, StartRow _ :=1, DataType:=xlFixedWidth, FieldInfo:=Array(Array(0, 2), Array(30, 9), Array _ (44, 9), Array(58, 1), Array(76, 1), Array(79, 9), Array(84, 9), Array(100, 9), Array(114, 1 _ ), Array(133, 9), Array(152, 9), Array(171, 9), Array(185, 9), Array(193, 9), Array(197, 9) _ , Array(201, 1), Array(204, 9), Array(242, 1), Array(245, 9)) ' Write the header Rows("1:1").Select Selection.Insert Shift:=xlDown With xlApp.Range("A1") .FormulaR1C1 = "TBA" .Offset(0, 1).FormulaR1C1 = "TBA" .Offset(0, 2).FormulaR1C1 = "TBA" .Offset(0, 3).FormulaR1C1 = "TBA" .Offset(0, 4).FormulaR1C1 = "TBA" .Offset(0, 5).FormulaR1C1 = "TBA" End With |
|
|
|
|
|
#2 |
|
Banned
Join Date: Feb 2002
Posts: 1,582
|
Hi Maslan
Try xlApp.ActiveSheet.Rows("1:1").Insert xlApp.ActiveSheet.Range("A1:F1") = "TBA" |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|