VBA Question; Selecting Non-Blank Cells and Pasting as Values

revolvermac

New Member
Joined
Jun 8, 2015
Messages
18
Hello all,

New to the forum as a poster but I've made use of a lot of the excellent advice and VBA code posted here for some time. Often I'm able to find just about anything to fit my needs, but I have a bit of a challenging coding question for you today.

I have a self-populating table that uses the following array formula (thanks to Rick Rothstein) to look up values for range A3:A40 from another table on a separate worksheet:

{=IFERROR(INDEX(Table1[Temp Name],SMALL(IF(Table1
Code:
="TERM",ROW(A$1:A$17)),ROWS(A$1:A1)))," ")}


Once the name is retrieved, I use basic VLOOKUP formulae to dump data into the rest of the columns present based on cell values in column A.

I'm setting up a macro to allow the administrator of the table to clear anyone with the "TERM" code on Table1; however, before doing that I need to paste any existing "TERM" names that have been captured by the array formula as values so that they don't vanish once the names are cleared from the source table.

The problem is that the array formula exists in each row and I need to avoid any "blank" rows from being pasted as I need the formula for any future changes that occur to Table1. The table is a living document that will need to be cleared on a routine basis.

Hopefully this is clear. I have VBA to clear the rows of anyone with the "TERM" code, however I need something that will select only cells that have data and aren't "blank". When I say "blank", I'm not talking about cells that are truly empty. The array formula simply returns a value of " " so that the cells LOOK blank. Right now I have the following set up:

Sub LockTerminated()
'
' LockTerminated Macro
'
'
    Sheets("Inactive").Select
    Range("Terminated").Select
    Selection.Copy
    Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
            xlNone, SkipBlanks:=True, Transpose:=False
End Sub

The problem with this of course is that there's nothing to dictate the selection of cells with values that aren't " ". That's the missing piece of this puzzle and from other threads I've looked at, this isn't an easy thing to work around.

Please ask for any clarification as I know this is a bit confusing - your help is greatly appreciated! :)
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).

Forum statistics

Threads
1,203,741
Messages
6,057,097
Members
444,905
Latest member
Iamtryingman

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top