# Macro to convert Table to a range



## howard (Dec 23, 2022)

I have written code below to convert a table to a range

However I get a run time error "object does'nt support this  property or method" and code below is highlighted


```
With .UsedRange
```


See full code



```
Sub ConvertTabletoRange()
With Worksheets("Reports Outstanding")
.ListObjects(1).Unlist
 With .Range("A1:D1").Font
.Bold = True
.Color = vbBlack
With .UsedRange
.Borders.LineStyle = xlContinuous
.Borders.Weight = xlThick
.Cells.Interior.ColorIndex = xlNone
   End With
      End With
        End With
     
End Sub
```


It would be apprciated if someone could kindly assist me


----------



## HaHoBe (Dec 23, 2022)

Hi howard,

small changes:


```
Sub ConvertTabletoRange()
With Worksheets("Reports Outstanding")
  .ListObjects(1).Unlist
  With .Range("A1:D1").Font
    .Bold = True
    .Color = vbBlack
  End With
  With .UsedRange
    .Borders.LineStyle = xlContinuous
    .Borders.Weight = xlThick
    .Cells.Interior.ColorIndex = xlNone
  End With
End With
End Sub
```

Ciao,
Holger


----------



## kevin9999 (Dec 23, 2022)

Another option...

```
Sub Convert()
    Dim r As Range
    If Worksheets("Reports Outstanding").ListObjects.Count > 0 Then
        With Worksheets("Reports Outstanding").ListObjects(1)
            Set r = .Range
            .Unlist
        End With
        
        With r
            With .Range(.Cells(1, 1), Cells(1, 4))
                .Font.Bold = True
                .Font.Color = vbBlack
            End With
            .Interior.ColorIndex = xlColorIndexNone
            .Borders.LineStyle = xlContinuous
            .Borders.Weight = xlThick
        End With
    End If
End Sub
```


----------



## howard (Dec 23, 2022)

Many Thanks Holger & Kevin


Code works perfectly


----------

