Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
I've written a function "CopyFromCell" (see below) that essentially copies a value from one cell to another, but with a feature. I use it to copy a source table to a destination table in a worksheet. The destination table always has the same number of rows (1-12 months), but the source table does not always contain that many rows (months). This is the trick; if there is a matching row(month) in the source table, copy the value, otherwise use 0 (zero). Public Function CopyFromCell(SourceCell As Range, MonthCell As Range) As Variant Set matchingMonthCell = Range("SourceMonths").Find(MonthCell.value, LookIn:=xlValues, LookAt:=xlWhole) If Not matchingMonthCell Is Nothing Then CopyFromCell = SourceCell Else CopyFromCell = 0 End If End Function This works fine initially, when the source and destination tables match. However, if I delete a row in the source table, I get a #REF! in the destination table, since it references a cell that has just been deleted. How do I get around this? I can still put the cursor on the desired position (say B35) in the excel sheet. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Use Advanced Filter to Detect non blank rows | Excel Discussion (Misc queries) | |||
How to detect excess rows in txt or csv files before opening? | Excel Programming | |||
How to detect excess rows in txt or csv files before opening? | Excel Programming | |||
How to detect and view more than 65,536 rows when opening a DBF | Excel Programming | |||
how to detect added or deleted rows in compare | Excel Programming |