ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Range help (https://www.excelbanter.com/excel-programming/296415-range-help.html)

hotherps[_54_]

Range help
 
HI, Im using the following code :

Dim myrange As Range

Set myrange = Range("D1")

For Each Cell In Range("D3:AJ19")

If Cell.Offset(0, -2) = myrange Then
For c = 0 To 7
Cell.Offset(0, c).Value = [E21]
Next c
End If
If c = 10 Then
End If
Next

I would like to continue running the same code through the entire range
of D1:AJ1. When I try to add it in to "myrange" I keep getting an
error.

Thanks


---
Message posted from http://www.ExcelForum.com/


Tom Ogilvy

Range help
 
Dim myrange As Range
Dim Cell as Range, Cell1 as Range
Dim c as Long
Set myrange = Range("D1:AJ1")

For Each Cell In Range("D3:AJ19")

for each cell1 in MyRange
If Cell.Offset(0, -2) = Cell1 Then
For c = 0 To 7
Cell.Offset(0, c).Value = [E21]
Next c
Exit For
End If
Next cell1
If c = 10 Then
End If
Next

Might be what you are asking.

--
Regards,
Tom Ogilvy


"hotherps " wrote in message
...
HI, Im using the following code :

Dim myrange As Range

Set myrange = Range("D1")

For Each Cell In Range("D3:AJ19")

If Cell.Offset(0, -2) = myrange Then
For c = 0 To 7
Cell.Offset(0, c).Value = [E21]
Next c
End If
If c = 10 Then
End If
Next

I would like to continue running the same code through the entire range
of D1:AJ1. When I try to add it in to "myrange" I keep getting an
error.

Thanks


---
Message posted from http://www.ExcelForum.com/





All times are GMT +1. The time now is 03:29 AM.

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