A
Alice21
Hi
I have the current VBA code which works really well in creating an
copying data to new tabs. All i want to do is to make sure when i
copies over the data in to new tabs that the text formatting copies ove
too. For example, the column headings are to be bold and the colum
containing time stays in a time format.
Can anyone help?
Sub CreateTabs()
Dim a, i As Long, j As Long, NR As Long, LR&, ws As Worksheet
Dim sName As String
Application.ScreenUpdating = False
For Each ws In ThisWorkbook.Worksheets
If ws.Name <> "Data" Then
ws.Cells.ClearContents
End If
Next
With Worksheets("Data")
a = .Range("a2").CurrentRegion.Value
End With
For i = 2 To UBound(a)
sName = a(i, 1) & "_EMA_FF"
If Not Evaluate("=ISREF('" & sName & "'!A1)") Then
Worksheets.Add(After:=Worksheets(Worksheets.Count)).Name
sName
End If
With Worksheets(sName)
NR = .Cells(Rows.Count, "a").End(xlUp).Row + 1
For j = 1 To UBound(a, 2)
.Cells(1, j) = a(1, j)
.Cells(NR, j) = a(i, j)
.Columns.AutoFit
Next
End With
Next
End Su
I have the current VBA code which works really well in creating an
copying data to new tabs. All i want to do is to make sure when i
copies over the data in to new tabs that the text formatting copies ove
too. For example, the column headings are to be bold and the colum
containing time stays in a time format.
Can anyone help?
Sub CreateTabs()
Dim a, i As Long, j As Long, NR As Long, LR&, ws As Worksheet
Dim sName As String
Application.ScreenUpdating = False
For Each ws In ThisWorkbook.Worksheets
If ws.Name <> "Data" Then
ws.Cells.ClearContents
End If
Next
With Worksheets("Data")
a = .Range("a2").CurrentRegion.Value
End With
For i = 2 To UBound(a)
sName = a(i, 1) & "_EMA_FF"
If Not Evaluate("=ISREF('" & sName & "'!A1)") Then
Worksheets.Add(After:=Worksheets(Worksheets.Count)).Name
sName
End If
With Worksheets(sName)
NR = .Cells(Rows.Count, "a").End(xlUp).Row + 1
For j = 1 To UBound(a, 2)
.Cells(1, j) = a(1, j)
.Cells(NR, j) = a(i, j)
.Columns.AutoFit
Next
End With
Next
End Su