After I import multiply files to different sheets. I import anywhere from 4 to 20 sheets
I run this loop to create formatted tables
The loop works great to format tables but Columns H & I text numbers only get converted on the last sheet even though I added it in the loop.
Here is my loop
This line also does nothing
Any direction would be appreciated, thanks
I run this loop to create formatted tables
The loop works great to format tables but Columns H & I text numbers only get converted on the last sheet even though I added it in the loop.
Here is my loop
Code:
Sub CreateAllSheetTables()
Dim lo As ListObject
Dim lRow As Long
Dim vTable As Variant
On Error GoTo CreateAllSheetTables_Error
' Loop to create Tables on all sheets Sheet Name is Table Name
For lSht = 2 To ActiveWorkbook.Worksheets.Count
With Worksheets(lSht)
.ListObjects.Add(xlSrcRange, .Range("$A$1").CurrentRegion, , xlYes).Name = "tbl" & .Name
' .ListColumns("extncost").DataBodyRange(lRow).Value = FormulaR1C1 = " =IF(ISNUMBER(SEARCH(""BOM"",A2)),0,H2*G2)" does not work
End With
'****************************************************************************************************
' Convert columns from text to numbers 481.400000 to $481.40
' This works only on last sheet table
Columns("H:H").Select
Selection.TextToColumns Destination:=Range("H1"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
Semicolon:=False, Comma:=False, Space:=False, Other:=False, FieldInfo _
:=Array(1, 1), TrailingMinusNumbers:=True
Selection.Style = "Currency"
Range("H1").Select
Columns("I:I").Select
Selection.TextToColumns Destination:=Range("I1"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
Semicolon:=False, Comma:=False, Space:=False, Other:=False, FieldInfo _
:=Array(1, 1), TrailingMinusNumbers:=True
Selection.Style = "Currency"
Range("I1").Select
Next lSht
Exit Sub
On Error GoTo 0
CreateAllSheetTables_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure CreateAllSheetTables of Sub m_ImportReportGenerator"
End Sub
This line also does nothing
Code:
.ListColumns("extncost").DataBodyRange(lRow).Value = FormulaR1C1 = " =IF(ISNUMBER(SEARCH(""BOM"",A2)),0,H2*G2)" does not work
Any direction would be appreciated, thanks