ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Range Definition (https://www.excelbanter.com/excel-programming/379494-range-definition.html)

[email protected]

Range Definition
 
I am trying to fill every column for B to whatever with "test".
I use following function to define the range. In this case Last_Column
= 12

Function Last_Column(My_Range As Range) As Long

Last_Column = Application.WorksheetFunction.CountA(My_Range)

End Function

Then I am using the Sub

Sub testa()

For j = 2 To Last_Column(Sheets("test").Rows("1:1"))

Sheets("test").Range(j & "2").Value = "test"

Next j

End Sub

Obvioysly I am not well defining the range. I guess I go wrong on
Range(j & "2").Value

Sorry to be so dumb/ignorant
and thanks for the help/merry xmas


[email protected]

Range Definition
 
Found it
Sheets("test").Cells(i, j).Value = "test"
Tks
Dan

On Dec 15, 11:12 am, wrote:
I am trying to fill every column for B to whatever with "test".
I use following function to define the range. In this case Last_Column
= 12

Function Last_Column(My_Range As Range) As Long

Last_Column = Application.WorksheetFunction.CountA(My_Range)

End Function

Then I am using the Sub

Sub testa()

For j = 2 To Last_Column(Sheets("test").Rows("1:1"))

Sheets("test").Range(j & "2").Value = "test"

Next j

End Sub

Obvioysly I am not well defining the range. I guess I go wrong on
Range(j & "2").Value

Sorry to be so dumb/ignorant
and thanks for the help/merry xmas




All times are GMT +1. The time now is 12:07 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com