Macro & VB101 and Excel

T

Ty

VB101
Sub Duplicate Data ()
'
' NOTE: You must select the first cell in the column and
' make sure that the column is sorted before running this macro
'
ScreenUpdating = False
FirstItem = ActiveCell.Value
SecondItem = ActiveCell.Offset(1, 0).Value
Offsetcount = 1
Do While ActiveCell <> ""
If FirstItem = SecondItem Then
ActiveCell.Offset(Offsetcount, 0).Interior.Color = RGB(255, 0,
0)
ActiveCell.Offset(Offsetcount - 1, 0).Interior.Color = RGB
(255, 0, 0)
Offsetcount = Offsetcount + 1
SecondItem = ActiveCell.Offset(Offsetcount, 0).Value
Else
ActiveCell.Offset(Offsetcount, 0).Select
FirstItem = ActiveCell.Value
SecondItem = ActiveCell.Offset(1, 0).Value
Offsetcount = 1
End If
Loop
ScreenUpdating = True
End Sub

It's been a long time. I'm trying to refresh my memory on VB. Is
there a way to view the counter?
I'm trying to understand each line by using debug to step through the
execution.
 
T

Ty

Put a watch on it, Debug>Add Watch...

--
__________________________________
HTH

Bob







- Show quoted text -

I know this might seem easy for most reading this. I want to view the
value of the counter. And this is the Offsetcount. Right??

Newbie Problem: I found it but a box came up with an Expression box.
Is the Offsetcount called an expression?

Note:: I used the help in Excel. But this seems greek to me, so far.

expression
A combination of keywords, operators, variables, and constants that
yields a string, number, or object. An expression can be used to
perform a calculation, manipulate characters, or test data.
 
T

Ty

I know this might seem easy for most reading this.  I want to view the
value of the counter.  And this is the Offsetcount.  Right??

Newbie Problem:  I found it but a box came up with an Expression box.
Is the Offsetcount called an expression?

Note::  I used the help in Excel.  But this seems greek to me, so far..

expression
A combination of keywords, operators, variables, and constants that
yields a string, number, or object. An expression can be used to
perform a calculation, manipulate characters, or test data.- Hide quoted text -

- Show quoted text -

I have my answer: Yes, Offsetcount is an expression. Excellent! The
WATCHES window is at the bottom of the screen. It keeps changing from
1 to 2 and back to 1. Wow!!! I also added the FirstItem which is a
Type:: Variant/String. My memory about VB & programming is slowly
coming back to me.

Do anyone have any more tips??
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top