![]() |
Need to Check Something
I have 2 files: FILE1 and FILE2
File1 has a 5 worksheets that begin with 101, 102, 103, 104 & 105 I need a code that if in FILE2 cell C14 there is a 101 and I'm in FILE worksheet 101 then it goes ahead and runs the rest of the macro, but i im in FILE1 , worksheet 102 and it sees a 101 in FILE2 then it stop and says WRONG FIL -- Message posted from http://www.ExcelForum.com |
Need to Check Something
Hi
try something like the following sub foo() dim wbk_1 as workbook dim wbk_2 as workbook dim wks_1 as worksheet dim wks_2 as worksheet dim test_value set wbk_1 = workbooks("file1.xls") set wks_1 = wbk_1.activesheet set wbk_2 = workbooks("file2.xls") set wks_2 = wbk_2.worksheets("sheet1") test_value = wks_2.range("C14").value if lcase(wks_1.name) <lcase(test_value) then msgbox "wrong sheet" exit sub end if 'your code comes here end sub -- Regards Frank Kabel Frankfurt, Germany I have 2 files: FILE1 and FILE2 File1 has a 5 worksheets that begin with 101, 102, 103, 104 & 105 I need a code that if in FILE2 cell C14 there is a 101 and I'm in FILE1 worksheet 101 then it goes ahead and runs the rest of the macro, but if im in FILE1 , worksheet 102 and it sees a 101 in FILE2 then it stops and says WRONG FILE --- Message posted from http://www.ExcelForum.com/ |
Need to Check Something
Thanks, you have me in the right direction... But, what if my workshee
is called 101NOW and 101-MAR How can I have it just check for the 101 in the worksheet name -- Message posted from http://www.ExcelForum.com |
Need to Check Something
Also, sometimes the check in the other file is not in C14 - it's alway
2 cells to the right from the word Location, heres what I have, how ca i integrate it: Set ofound = Cells.Find(WHAT:="LOCATION", _ After:=ActiveCell, _ LookIn:=xlFormulas, _ LookAt:=xlPart, _ SearchOrder:=xlByColumns, _ SearchDirection:=xlNext, _ MatchCase:=True) If Not ofound Is Nothing Then ofound.Activate If Trim(ofound) = "DDC" Then ActiveCell.Offset(rowOffset:=0, columnOffset:=2).Activat -- Message posted from http://www.ExcelForum.com |
Need to Check Something
Hi
change the line if lcase(wks_1.name) <lcase(test_value) to if lcase(left(wks_1.name,3)) <lcase(test_value) -- Regards Frank Kabel Frankfurt, Germany Thanks, you have me in the right direction... But, what if my worksheet is called 101NOW and 101-MAR How can I have it just check for the 101 in the worksheet name? --- Message posted from http://www.ExcelForum.com/ |
All times are GMT +1. The time now is 11:59 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com