Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
if not found, add/insert
I have a worksheet, sheet 1, with Name, Date, Hours, and WorksheetName
They fill these value and runs this code with Name Date and Hours: ENAME = Sheets("sheet1").Range("a14", "a14").Value EDate = Sheets("sheet1").Cells(7, 8).Value EHOURS = Sheets("sheet1").Range("a20", "a20").Value flName = "TIME SHEETS.xls" flPath = "C:\Documents and Settings\Jon Monagan\My Documents\Gary\" OpenSheet = Sheets("sheet1").Cells(18, 5).Value If Not WorkbookIsOpen(flName) Then Workbooks.Open (flPath & flName) Set wbTS = Workbooks(flName) wbTS.Activate wbTS.Sheets(OpenSheet).Activate lRow = wbTS.Sheets(OpenSheet).Columns(1).Cells.Find(ENAME , LookIn:=xlValues).Row iCol = wbTS.Sheets(OpenSheet).Rows(1).Cells.Find(EDate, LookIn:=xlValues).Column wbTS.Sheets(OpenSheet).Cells(lRow, iCol) = EHOURS AND/Or THIS CODE with Name Date Hours And WorksheetNAme: flName = "MISC. HOUR COMP.xls" flPath = "C:\Documents and Settings\Jon Monagan\My Documents\Gary\" OpenSheet = "Data" If Not WorkbookIsOpen(flName) Then Workbooks.Open (flPath & flName) Set wbTS = Workbooks(flName) wbTS.Activate wbTS.Sheets(OpenSheet).Activate What I need is something to add to these that if it can't find the name or date in the first block of code, add the date or name In the second block of code I need something that will insert a new worksheet and name it the specified name if it can't find it. Any ideas? or direction --- Message posted from http://www.ExcelForum.com/ |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
What is a BTW? Where can BTWs be found? | Excel Discussion (Misc queries) | |||
Look up a value in one colum and insert the value found in the adj | New Users to Excel | |||
IF NOT FOUND | Excel Worksheet Functions | |||
Search for a test string and if found insert 'x' in clumn 'A' | Excel Discussion (Misc queries) | |||
not found | Excel Programming |