Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / November 2007

Tip: Looking for answers? Try searching our database.

Step through cells in a selected range

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
CLR - 21 Nov 2007 16:31 GMT
Hi All.......

I can step through the cells in a column ok, but need help now in stepping
through all the cells in a selected RANGE, (say C3:e7), and perform a task
against each cell.

Any help would be much appreciated.

Vaya con Dios,
Chuck, CABGx3
Ed from AZ - 21 Nov 2007 16:43 GMT
Sub XX_CellsInRng()

Dim rng As Range
Dim cll As Range

Set rng = Selection
For Each cll In rng
 Debug.Print cll.Value
Next cll

End Sub

Cheers!
Ed

> Hi All.......
>
[quoted text clipped - 6 lines]
> Vaya con Dios,
> Chuck, CABGx3
CLR - 21 Nov 2007 17:09 GMT
Hi Ed...........
This works great, much thanks...... but one more favor if you please........

Sub XX_CellsInRng()
Dim rng As Range
Dim cll As Range
Set rng = Selection
For Each cll In rng
  If cll.Value < 1000 And cll.Value <> "" Then
  cll.Value = 1001
  End If
Next cll
End Sub

How can I specifically exclude a cell containing TEXT from the cll.value test?

Vaya con Dios,
Chuck, CABGx3

> Sub XX_CellsInRng()
>
[quoted text clipped - 21 lines]
> > Vaya con Dios,
> > Chuck, CABGx3
Hemant_india - 21 Nov 2007 17:44 GMT
hi
see if this works
Sub XX_CellsInRng()
Dim rng As Range
Dim cll As Range
Set rng = Selection
For Each cll In rng
if not istext(cll.text) then
If cll.Value < 1000 And cll.Value <> "" Then
cll.Value = 1001
End If
end if
Next cll
End Sub

Signature

hemu

> Hi Ed...........
> This works great, much thanks...... but one more favor if you please........
[quoted text clipped - 40 lines]
> > > Vaya con Dios,
> > > Chuck, CABGx3
CLR - 21 Nov 2007 17:57 GMT
Hi Hemant_india.....

Your code didn't work directly for me, (I forgot to mention I'm using XL97),
but this slight modification of it did work fine..........

Sub XX_CellsInRng()
Dim rng As Range
Dim cll As Range
Set rng = Selection
For Each cll In rng
If IsNumeric(cll.Value) Then
If cll.Value < 1000 And cll.Value <> "" Then
cll.Value = 1001
End If
End If
Next cll
End Sub

Thanks very much for heading me in the right direction.

Vaya con Dios,
Chuck, CABGx3

> hi
> see if this works
[quoted text clipped - 55 lines]
> > > > Vaya con Dios,
> > > > Chuck, CABGx3
CLR - 21 Nov 2007 18:01 GMT
Hi Hemant_india.....

Your code didn't work directly for me, (I forgot to mention I'm using XL97),
but this slight modification of it did work fine..........

Sub XX_CellsInRng()
Dim rng As Range
Dim cll As Range
Set rng = Selection
For Each cll In rng
If IsNumeric(cll.Value) Then
If cll.Value < 1000 And cll.Value <> "" Then
cll.Value = 1001
End If
End If
Next cll
End Sub

Thanks very much for heading me in the right direction.

Vaya con Dios,
Chuck, CABGx3

> hi
> see if this works
[quoted text clipped - 55 lines]
> > > > Vaya con Dios,
> > > > Chuck, CABGx3
CLR - 21 Nov 2007 18:04 GMT
Hi Hemant_india.....

Your code didn't work directly for me, (I forgot to mention I'm using XL97),
but this slight modification of it did work fine..........

Sub XX_CellsInRng()
Dim rng As Range
Dim cll As Range
Set rng = Selection
For Each cll In rng
If IsNumeric(cll.Value) Then
If cll.Value < 1000 And cll.Value <> "" Then
cll.Value = 1001
End If
End If
Next cll
End Sub

Thanks very much for heading me in the right direction.

Vaya con Dios,
Chuck, CABGx3

> hi
> see if this works
[quoted text clipped - 55 lines]
> > > > Vaya con Dios,
> > > > Chuck, CABGx3
CLR - 21 Nov 2007 18:07 GMT
As you can see..........I'm having a little trouble with the Newsgroup
interface....sorry for the multiple posts, but three "thank you's" is better
than none.

Vaya con Dios,
Chuck, CABGx3

> Hi Hemant_india.....
>
[quoted text clipped - 78 lines]
> > > > > Vaya con Dios,
> > > > > Chuck, CABGx3
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.