i made a function to open file and import its data to another worksheet so i need to use check box as a validation so that when the file is uploaded the check box is marked so is there an option to mark check box after the file is imported and data is copied
i thought of a possible solution but i do not know if it is a good one or there is another better solution: i though to create a check box on worksheet named First where i need it to be created and using the imported data of the opened file which are pasted at another worksheet in the same workbook named Second to check if the range A1:A to last row of A contains a specific text for example: A1 and A2 and A3 and A4 contains text XX,YY,ZZ,MM and may XX,YY,ZZ,MM not exists in order in the A1:A range
For more clairfication A1=ZZ A2= XX A3=MM A4=XX A5=yy and so on , so is there an option to search for XX in A2: last row of A and when it is found, the check box on the sheet named first is checked.
Dim FileToOpen5 As Variant
Dim OpenBook5 As Workbook
FileToOpen5 = Application.GetOpenFilename(Title:="Browse for your File & Import Range", FileFilter:="Excel Files (*.xls*),*xls*")
If FileToOpen5 <> False Then
Set OpenBook5 = Application.Workbooks.Open(FileToOpen5)
Set Ssheet5 = OpenBook5.Worksheets("Default")
SaveChanges = False
OpenBook5.Close
End If
'Selecting Destination and last row to copy the data after it
Set DestShtBPSV = ThisWorkbook.Worksheets("Second")
Dim LR_DestShtBV As Long
LR_DestShtBV = DestShtBPSV.Cells(DestShtBPSV.Rows.Count, "B").End(xlUp).Offset(1).Row
'Select LastRow of the imported file
Dim LastRowAV As Long
LastRowAV = Ssheet5.Cells(Ssheet5.Rows.Count, "A").End(xlUp).Offset(1).Row
Ssheet5.Range("A2:A" & LastRowAV).Copy Destination:=DestShtBPSV.Cells(LR_DestShtBV, "D")
OpenBook5.Save
OpenBook5.Close True
Aucun commentaire:
Enregistrer un commentaire