PDA

View Full Version : vba code move cell to next cell



etheer
02-27-2014, 08:17 PM
Hi
Please help me i need vba code work automatically move cell to next cell

If cell C > 1000 move to cell B

ashleyuk1984
02-28-2014, 02:39 AM
This should do the trick.


Sub MoveCell()
Dim LastRow As Integer

LastRow = Range("C9999").End(xlUp).Row

For x = 1 To LastRow
If Range("C" & x).Value > 1000 Then Range("C" & x).Cut Destination:=Range("B" & x)
Next x

End Sub

westconn1
02-28-2014, 02:42 AM
is this what you need?

For Each cel In Range("c:c")
If IsEmpty(cel) Then Exit For ' finish on empty cell
If cel > 1000 Then cel.Offset(, -1).value = cel: cel.ClearContents
Next

etheer
02-28-2014, 05:52 AM
is this what you need?

For Each cel In Range("c:c")
If IsEmpty(cel) Then Exit For ' finish on empty cell
If cel > 1000 Then cel.Offset(, -1).value = cel: cel.ClearContents
Next




thank you westconn
please download this file

ashleyuk1984
02-28-2014, 09:13 AM
WHAT THE !!!????
Everything is backwards lol... Is this how Arabic worksheets look ??

Anyway, we've given you two codes already that does the job... Try modifying the code yourself to complete your whole task. You must have the willingness to learn. :)

Bob Phillips
02-28-2014, 09:43 AM
WHAT THE !!!????
Everything is backwards lol... Is this how Arabic worksheets look ??

Yes of course, they read right to left. So, to them, it is not backwards.

Bob Phillips
02-28-2014, 09:47 AM
Put this code in the worksheet code module


Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit

Application.EnableEvents = False

If Not Intersect(Target, Me.Columns(1)) Is Nothing Then

If Target.Value > 1000 Then

Me.Cells(Target.Row, Me.Columns.Count).End(xlToLeft).Offset(0, 1).Value = Target.Value
End If
End If

ws_exit:
Application.EnableEvents = True
End Sub

etheer
02-28-2014, 10:23 AM
thank you xld
code work 100%

mancubus
03-01-2014, 12:29 PM
i found myself googling "which languages are written RTL?" :rofl:

and why LTR or RTL?

this theory seems OK to me.



Many languages that existed before the invention of ink were written right to left since this is the more natural for right handed people to hold a chisel in the left hand and the hammer in the right. After ink became the main method of writing, writing from left to right became preferable since it avoided smudging the ink.

Aussiebear
03-01-2014, 04:31 PM
and thus the world of left handers became a little harder.