Search : in
By :

Vba loop jumping ower values

Last answer on Jul 21, 2009 1:51:28 pm BST Da helpzor, on Jul 21, 2009 12:41:21 pm BST 
 Report this message to moderators

Hello,

i have created a loop witch is a part of a bigger macro i am creating the loop is runnig fine exept one thing, the loops pupuse is to compare data and if value ""X"" > ""Y"" then replase Y with X the issue is this if a collum look like this

3
4
5
6
7


the loop ends up wit 5 as end value and if i run it one more time it will end up with 7 witch is waht i want but wy dosent it do that the first time ? here is the code

i get the impression that the loop copis the first then jump ower the last numbers

Range("B10").Select
Dim k As Integer
Dim i As Integer
Application.ScreenUpdating = False

For y = 1 To 100000
If ActiveCell = Range("J9").Offset(0, i) And ActiveCell.Offset(0, 2) = Range("I10").Offset(k, 0) And ActiveCell.Offset(0, 3).Value > Range("j10").Offset(k, i).Value Then
ActiveCell.Offset(0, 3).Copy
Range("J10").Offset(k, i).PasteSpecial
ActiveCell.Offset(1, 0).Select

Else
ActiveCell.Offset(1, 0).Select
End If

If IsEmpty(ActiveCell) Then
Range("B10").Select
k = k + 1
End If

If k > 70 Then
k = 0
i = i + 1
End If
If i > 20 Then
i = 0
k = 0
End If

Next y

Application.ScreenUpdating = True

i am grateful for any help

Configuration: office 2003

Best answers for « vba loop jumping ower values » in :
[VBA] Detecting changes in cell Show [VBA] Detecting changes in cell The Event Change feature of a sheet will detects the change in the active cell but it gives no information about the content. The example given below will help you to find out if the cell was changed,...
[VBA] A function that returns the color of an active MFC Show[VBA] A function that returns the color of an active MFC This function returns the value of the active format in conditional formatting. With the function below, two values can be returned. Mode = 0: the value of Interior.ColorIndex...
[VBA/VB6] My Documents + Environment Variables Show[VBA/VB6] My Documents + Environment Variables With VBA With VB6 Environment Functions Windows Variables Getting started As displayed in Windows Explorer, the My Documents folder appears to be in the root, but it is not the case. It...
How to read a file line by line ShowHow to read a file line by line Intro Tips Bonus Intro One of the most common errors of learning scripts bash on GNU / Linux is to read a file line by line, is to use a loop "for" (for line in $ (cat file.txt) do. ..), which in this...
Spreadsheets - Conditional expressions ShowWhat is a Conditional Structure? Conditional structures are instructions that allow to test if a condition is true or not. Conditional structures may be associated together. To successfully execute these tests using logical functions, spreadsheets...
ADSL - Local loop unbundling ShowIntroduction to local loop unbundling The part of the telephone line arriving at the subscriber is called the "local loop". In order to use high speed internet (ADSL), Internet Service Providers (ISP) must install connection hardware to their...

1

 Da helpzor, on Jul 21, 2009 1:51:28 pm BST
  • +1

O.o

i fixd it just cahnged

ActiveCell.Offset(0, 3).Copy
Range("J10").Offset(k, i).PasteSpecial


to

ActiveCell.Offset(0, 3).Copy Destination:=Range("J10").Offset(k, i)


:)

Reply to Da helpzor