View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Xxer Xxes Xxer Xxes is offline
external usenet poster
 
Posts: 33
Default Avoid ,,Select" and ,,Selection" in a few lines of code

Thanks a lot for response .

With DestWks
For Each myCell In myRng1.Cells
If myCell < 3 Then
myCell = myCell.Value + 1
is wrong . I need if in myCell value is < 3 ,
then , myCell.Offset(0, -4 ) to increment its own value
with value ,,1" ;
so , if in myCell.Offset(0,-4) the value is 235 , it must became
236 ;


Well this above part I have fixed it :

If myCell < 3 Then
myCell.Offset(0, -4) = myCell.Offset(0, -4).Value + 1

This line of code make me what I need . The above part was solved , working
with your code.
- - - - -
but here , lines of code below, I still have a trouble , and in this macro is my last task
I have to accomplish :

myCell.Offset(0, -4).Cut _
Destination:=.Cells(myCell.Row, Columns.Count).End(xlToLeft).Offset(0, 1)


,,Columns.Count " starts to count from last column .
I have 5 more columns after
Column(BA) , ( it means Column(BA) ,, to the right " ) ; I use olso and the ,,myCell.Offset(0, -4)" Column with data , that means Column(AW) ,
and the ,,Cut" value must go to range IN THE LEFT of Column (AW) , when it found data
. This last part , ,,Offset(0, 1)" work very well , but the ,,Count" must begin not from last column from sheet but as i just have described .