ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Macro & VB101 and Excel (https://www.excelbanter.com/excel-worksheet-functions/238313-macro-vb101-excel.html)

Ty

Macro & VB101 and Excel
 
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.

Bob Phillips[_3_]

Macro & VB101 and Excel
 
Put a watch on it, DebugAdd Watch...

--
__________________________________
HTH

Bob

"Ty" wrote in message
...
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.




Ty

Macro & VB101 and Excel
 
On Jul 29, 6:43*am, "Bob Phillips" wrote:
Put a watch on it, DebugAdd Watch...

--
__________________________________
HTH

Bob

"Ty" wrote in message

...



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.- Hide quoted text -


- 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.

p45cal[_6_]

Macro & VB101 and Excel
 

Cross posted he
'Yahoo! Groups'
(http://tech.groups.yahoo.com/group/m.../message/35293)

Ty;435112 Wrote:
On Jul 29, 6:43*am, "Bob Phillips" wrote:
Put a watch on it, DebugAdd Watch...

--
__________________________________
HTH

Bob

"Ty" wrote in message


...



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.- Hide quoted text -


- 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.



--
p45cal

*p45cal*
------------------------------------------------------------------------
p45cal's Profile: http://www.thecodecage.com/forumz/member.php?userid=558
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=120533



All times are GMT +1. The time now is 08:21 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com