Search through Row and Column, inserting shape where match is found

vrobles53

New Member
Joined
Jun 4, 2019
Messages
1
Hello All, thank you for your help

I am looking for a VBA/Macro that will sort through each cell in column "E" (dates) and compare it to each cell in a row 1 "H1:BE1". When a matching date is found I would like the code to insert a shape or value into the respective cell. My code is below, however it is very rough. I cannot seem to have the code move with the for loop.

Code:
[TABLE="width: 76"]
<colgroup><col></colgroup><tbody>[TR]
[TD]Sub Attempt_6()[/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD]Dim cel As Range[/TD]
[/TR]
[TR]
[TD]Dim rng As Range[/TD]
[/TR]
[TR]
[TD]Dim ws As Worksheet[/TD]
[/TR]
[TR]
[TD]Sheets("Andrew").Range("U3: W16").ClearContents[/TD]
[/TR]
[TR]
[TD]     For Each cel In Range("U1:W1")[/TD]
[/TR]
[TR]
[TD]'        For Each rng In Range("A3:A4")[/TD]
[/TR]
[TR]
[TD]        If cel.Value = Range("A4") Then[/TD]
[/TR]
[TR]
[TD]  [/TD]
[/TR]
[TR]
[TD]        Range("A1").Copy 'Range("U4:W5")[/TD]
[/TR]
[TR]
[TD]        Cells(4, Columns.Count).End(xlToLeft).Offset(0, 1).PasteSpecial xlPasteFormulas[/TD]
[/TR]
[TR]
[TD]        [/TD]
[/TR]
[TR]
[TD]        Else[/TD]
[/TR]
[TR]
[TD]        Range("A2").Copy[/TD]
[/TR]
[TR]
[TD]        Cells(4, Columns.Count).End(xlToLeft).Offset(0, 1).PasteSpecial xlPasteFormulas[/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD]    End If[/TD]
[/TR]
[TR]
[TD]    Next cel[/TD]
[/TR]
[TR]
[TD]    [/TD]
[/TR]
[TR]
[TD]End Sub[/TD]
[/TR]
</tbody>[/TABLE]

Any help or guidance would be greatly appreciated.

Cheers!
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Hello All, thank you for your help

I am looking for a VBA/Macro that will sort through each cell in column "E" (dates) and compare it to each cell in a row 1 "H1:BE1". When a matching date is found I would like the code to insert a shape or value into the respective cell. My code is below, however it is very rough. I cannot seem to have the code move with the for loop.

Any help or guidance would be greatly appreciated.

Cheers!

Welcome to the forum.

I attach the macro based on your description.
Assuming that your data starts in cell E2

The cell format in H1:BE1 must be dd/mm/yyyy. In the respective cell will put an "x"

Code:
Sub Macro1()
    Dim c As Range, f As Range
    For Each c In Range("[COLOR=#ff0000]E2", Range("E"[/COLOR] & Rows.Count).End(xlUp))
        Set f = Range("H1:BE1").Find(c.Value, LookIn:=xlValues, lookat:=xlWhole)
        If Not f Is Nothing Then
            Cells(c.Row, f.Column).Value = "[COLOR=#ff0000]x[/COLOR]"
        End If
    Next
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,177
Members
453,021
Latest member
Justyna P

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