Question about dates.

superbeast326

Board Regular
Joined
Nov 12, 2011
Messages
132
I have two columns, A and B. Both have 50 rows. Column A is filled entirely with "No". What I want is that the moment I switch a row in Column A to "Yes". I want the row in Column B to store the date that the change was made. Is this possible?
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Re: Help in understanding VBA Code in another thread

It's good that you want to understand the code. Too many just take the fish without showing any interest in learning how to fish. {grin}

Take the time to figure this out for yourself and you will also learn how to write code and if not write better code. {smile}

Understand code
http://www.tushar-mehta.com/excel/vba/vba-Understand code.htm

Before I begin, I would like to extend my gratitude to Peter_SSs, for his time and patience in answering my questions in the thread titled, "Question about Dates".

In another thread, created by me, he gave me a VBA Code to help me with a problem. The only problem is that, I do not understand why the code works the way it does. Here is the code:
Code:
[FONT=Courier][COLOR=#00007F]Sub[/COLOR] DV()
    [COLOR=#00007F]Dim[/COLOR] Rng1 [COLOR=#00007F]As[/COLOR] Range, Rng2 [COLOR=#00007F]As[/COLOR] Range, c [COLOR=#00007F]As[/COLOR] Range
    [COLOR=#00007F]Dim[/COLOR] rowdiff [COLOR=#00007F]As[/COLOR] [COLOR=#00007F]Long[/COLOR], coldiff [COLOR=#00007F]As[/COLOR] [COLOR=#00007F]Long[/COLOR]
    [COLOR=#00007F]Dim[/COLOR] DVvals [COLOR=#00007F]As[/COLOR] [COLOR=#00007F]String[/COLOR]
    
    [COLOR=#00007F]Set[/COLOR] Rng1 = Range("C3:C4")   [COLOR=#007F00]'<- Change to suit[/COLOR]
    [COLOR=#00007F]Set[/COLOR] Rng2 = Range("F5:F6")   [COLOR=#007F00]'<- Change to suit[/COLOR]
    [COLOR=#00007F]If[/COLOR] Rng1.Rows.Count = Rng2.Rows.Count And _
            Rng1.Columns.Count = Rng2.Columns.Count [COLOR=#00007F]Then[/COLOR]
        rowdiff = Rng1.Row - Rng2.Row
        coldiff = Rng1.Column - Rng2.Column
        Rng2.Validation.Delete
        [COLOR=#00007F]For[/COLOR] [COLOR=#00007F]Each[/COLOR] c [COLOR=#00007F]In[/COLOR] Rng2.Cells
            DVvals = c.Offset(rowdiff, coldiff).Value
            DVvals = Replace(DVvals, " vs ", ",", 1, -1, vbTextCompare)
            [COLOR=#00007F]If[/COLOR] Len(DVvals) > 0 [COLOR=#00007F]Then[/COLOR]
                [COLOR=#00007F]With[/COLOR] c.Validation
                    .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, _
                        Operator:=xlBetween, Formula1:=DVvals
                    .IgnoreBlank = [COLOR=#00007F]True[/COLOR]
                    .InCellDropdown = [COLOR=#00007F]True[/COLOR]
                    .InputTitle = ""
                    .ErrorTitle = ""
                    .InputMessage = ""
                    .ErrorMessage = ""
                    .ShowInput = [COLOR=#00007F]True[/COLOR]
                    .ShowError = [COLOR=#00007F]True[/COLOR]
                [COLOR=#00007F]End[/COLOR] [COLOR=#00007F]With[/COLOR]
            [COLOR=#00007F]End[/COLOR] [COLOR=#00007F]If[/COLOR]
        [COLOR=#00007F]Next[/COLOR] c
    [COLOR=#00007F]End[/COLOR] [COLOR=#00007F]If[/COLOR]
[COLOR=#00007F]End[/COLOR] [COLOR=#00007F]Sub
[COLOR=black]
[/COLOR][/COLOR][/FONT]


Could someone please take the time to explain to me the above code, line by line.
 
Upvote 0
Re: Help in understanding VBA Code in another thread

Could you please explain to me the purpose of the following line of codes:
1.
Code:
[FONT=Courier]   [COLOR=#00007F]If[/COLOR] Rng1.Rows.Count = Rng2.Rows.Count And _                  Rng1.Columns.Count = Rng2.Columns.Count [COLOR=#00007F]Then[/COLOR]                    rowdiff = Rng1.Row - Rng2.Row         
             coldiff = Rng1.Column - Rng2.Column                    Rng2.Validation.Delete

and

[/FONT]
[FONT=Courier]  [COLOR=#00007F]If[/COLOR] Len(DVvals) > 0 [COLOR=#00007F]Then[/COLOR][/FONT]

 
Upvote 0
I merged your two threads together, as we do not want to start a new thread on the same topic. Threads of a duplicate nature are typically locked or deleted, per forum rules. You want to continue on in the same thread, since it is in reference to the question you had answered in the other thread.
 
Upvote 0
Can someone please help me understand the code, every time I get close to understanding, I end up at the starting point again. I need to understand the logic
 
Upvote 0
What do you want help with?

In one of your earlier posts you indicated you wanted an explanation of the only 2 If statements in the code.

Is that what you want help with? An If statement? If so, you should start by searching Excel VBA help for 'If Then Else' (w/o the quotes).

Or do you want help with something specifically within the If statement? if so, what?
Can someone please help me understand the code, every time I get close to understanding, I end up at the starting point again. I need to understand the logic
 
Upvote 0

Forum statistics

Threads
1,216,503
Messages
6,131,020
Members
449,615
Latest member
Nic0la

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top