VBA that combine the texts in two cells, then search in a spesific folder and if it exists return "Yes" if not "No"

burchette

New Member
Joined
May 30, 2018
Messages
11
Hello people,

I have some drawing list of the project and that will be changed because of the revisions and statements and the new ones of course.

[TABLE="width: 266"]
<colgroup><col><col></colgroup><tbody>[TR]
[TD]05.02-2602-06-0001[/TD]
[TD]E10[/TD]
[/TR]
[TR]
[TD]05.02-2602-06-0002[/TD]
[TD]E09[/TD]
[/TR]
[TR]
[TD]05.02-2602-06-0003[/TD]
[TD]E11[/TD]
[/TR]
</tbody>[/TABLE]

First column is the drawing numbers and the second one is revision numbers. Can you help me to proceed in how can I create a code that combine this in "05.02-2602-06-0001_E10" format and search for it in a spesific folder whether it exists and write "Yes" or "No" in another column.

It sounds easy when I searched others which are similar to this, but I have no idea about VBA. Can you help or direct me to a place, this is one year job, it will be a baseline for me.
[TABLE="width: 266"]
<colgroup><col><col></colgroup><tbody></tbody>[/TABLE]
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Try
change the path to your path
I assume the columns used are A, B, and C with headers in row 1


Code:
Sub drawexists()
Dim lr As Long
Dim fname As String
Dim mypath As String
lr = Cells(Rows.Count, "A").End(xlUp).Row 'find last used row in column A
mypath = "C:\drawing\" 'change to your path
For x = 2 To lr
    fname = Cells(x, "A") & "_" & Cells(x, "B")    
  
    If Dir(mypath & fname & ".*") <> "" Then
        Cells(x, "C") = "Yes"
    Else
        Cells(x, "C") = "No"
    End If
Next x

End Sub
 
Upvote 0
Thanks a lot at first.

I made my arrangements for the names and directory but it could not find anyone of them. Then I tried to change the extension to the ".dwg" in Dir function, but again all results appeared as "No"

I could not manage I guess.
 
Upvote 0
Check that your directory and file names match, no extra spaces and are properly spelled.
 
Upvote 0

Forum statistics

Threads
1,224,828
Messages
6,181,214
Members
453,024
Latest member
Wingit77

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