ANTONIO1981
Board Regular
- Joined
- Apr 21, 2014
- Messages
- 162
Hi All
Below *code works for the following:
- sheet "EMPLOYEE_OH" has 17 columns (A to Q)
- sheet "EMPLOYEE_OH_TABLE" displays 6 columns
The new code needs to take into account the following:in my new sheet "EMPLOYEE_OH" column E is going to disappear
Hence in the new sheet "EMPLOYEE_OH_TABLE column C is going to disappear
*
thanks in advance
Below *code works for the following:
- sheet "EMPLOYEE_OH" has 17 columns (A to Q)
- sheet "EMPLOYEE_OH_TABLE" displays 6 columns
The new code needs to take into account the following:in my new sheet "EMPLOYEE_OH" column E is going to disappear
Hence in the new sheet "EMPLOYEE_OH_TABLE column C is going to disappear
*
Code:
Sub EMPLOYEE_OH_TABLE()
Dim Ray As Variant, n As Long, Ac As Long, c As Long
Ray = Sheets("EMPLOYEE_OH").Range("A1").CurrentRegion.Resize(, 17)
ReDim nray(1 To UBound(Ray, 1) * UBound(Ray, 2) + 1, 1 To 6)
c = 1
nray(c, 1) = Ray(1, 1)
nray(c, 2) = Ray(1, 2)
nray(c, 3) = Ray(1, 3)
nray(c, 4) = Ray(1, 4)
nray(c, 5) = "Date"
nray(c, 6) = "Amount"
For n = 2 To UBound(Ray, 1)
For Ac = 5 To UBound(Ray, 2)
c = c + 1
nray(c, 1) = Ray(n, 1)
nray(c, 2) = Ray(n, 2)
nray(c, 3) = Format(Ray(n, 3), "mmm_yy")
nray(c, 4) = Ray(n, 4)
If IsDate(Ray(1, Ac)) Then
nray(c, 5) = CDate(Ray(1, Ac))
Else
nray(c, 5) = Ray(1, Ac)
End If
nray(c, 6) = Format(Ray(n, Ac), "#,##0.00000")
Next Ac
Next n
Sheets("EMPLOYEE_OH_TABLE").Range("A1").Resize(c, 6) = nray
End Sub
thanks in advance
Last edited: