I need to count the number of columns within a variable range and use the address of the last column to form part of defined range. Once I have defined the range I will want to input a formula. Can anyone please help?

Example

```
Dim lastcolumn as string

Lastcolumn = sheet("test").range("a1").end(xltoright).column

Sheets("test").range("b1:" & lastcolumn).select

Selection.formula = "myformula"

```