Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default 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/

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default 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/

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
make a check form, and then have info go to a check register richie g Excel Worksheet Functions 0 May 5th 10 12:10 AM
Copy and move check box (check boxes) with new cell link? Marty Excel Worksheet Functions 1 January 20th 10 07:43 PM
Increase size of a Forms Check Box (click on to enter check mark) 718Satoshi Excel Discussion (Misc queries) 0 August 17th 07 01:52 AM
Check if Conditional Format is True or False / Check cell Color Kevin McCartney Excel Worksheet Functions 5 June 29th 07 11:12 AM
Enable check box in protected sheet + group check boxes Dexxterr Excel Discussion (Misc queries) 4 August 2nd 06 12:00 PM


All times are GMT +1. The time now is 06:30 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"