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 / New Users / November 2007

Tip: Looking for answers? Try searching our database.

Selecting cells in the same row  in various columns for     ClearingContents

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ed - 27 Nov 2007 17:03 GMT
(This is a portion of my macro which loops through multiple sheets,
each with various rows of data to test)

Sub OpenSheet1()                                   [ Sheet has a Name]
'Opens Sheet 1 for clearing sold out items
   Worksheets("Sheet1").Activate
   Range("M2").Activate
   Dim rwindex As Integer                         [rwindex is row
number]
   For rwindex = 2 To Range("data") + 1     [ "data" is number of
items in the sheet.  Row "rwindex",  starts at 2)
   rwindex = rwindex
   If Cells(rwindex, 13).Value = 0 Then        [This tests the cell
value down rows, COL 13, (M), constant]
   Range("rwindex, 1").Activate                  [THIS is my
DILEMMA]????????
   ActiveCell.Select
   Selection.ClearContents

My loop works until Value 0 is found, then this fails.
I need to select the cell in ("rwindex, 1")..COL A.  There are other
cells in rwindex to clear also.

I've tried to use Range (Array of 9  contiguous cells, then 3 other
non-contiguous, in order to clear contents.   Macro Recording used
cell addresses, A5, B5, etc.  I don't have that info.
My Arrays did not function, so, the above macro selects one cell at a
time.  I can live with that.

HOWEVER:
Range("rwindex, 1").Activate (Or Select)    This does not work for
selecting "rwindex, 1" as Col 1, (A ,etc)
As this is looping Col M, (13), I have no way of knowing in which row
a cell value is 0, and how to select the cells to clear.

I've used Scrolling, down, left, right, and have not found a  way to
Select or Activate the cell,  for it's Value.

Thanks for any help.  I've searched for 2-3 weeks for a solution.

Ed
Don Guillett - 27 Nov 2007 17:13 GMT
try something like this where you do NOT select anything including the
sheet.

With sheets("sheet1").Range("m1:m100")
   Set c = .Find(0, lookin:=xlValues)
   If Not c Is Nothing Then
       firstAddress = c.Address
       Do
c.clearcontents
c.offset(,2).clearcontents
'etc
           Set c = .FindNext(c)
       Loop While Not c Is Nothing And c.Address <> firstAddress
   End If
End With

Signature

Don Guillett
Microsoft MVP Excel
SalesAid Software
dguillett1@austin.rr.com

> (This is a portion of my macro which loops through multiple sheets,
> each with various rows of data to test)
[quoted text clipped - 37 lines]
>
> Ed

Rate this thread:






 
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.