Blank cells as result of formula with ""

Joe78man

New Member
Joined
Nov 26, 2018
Messages
15
Hello guys,

I'm making a macro that finds the last empty cell and paste from there, the problem I'm having is that Excel won't consider an empty cell when copying a cell which formula's result is "" and pasting values, hence, the macro leaves as many empty cells as where copied from blank cells (as result of a formula)

It's kinda hard to explain so I will ilustrate:

Cell A1:
=IFERROR(INDEX(Summary!$AA:$AA,MATCH(COUNTA($H$14:H14),Summary!$AK:$AK,0)),"")
let's say there is an error and the cell value is ""

Macro button would copy A1 and paste values at B1 (just to ilustrate)
B1 looks empty, but when I use ctrl+arrows to move it stops there as if it had an actual value. I tried skipping blanks but it seems excel considers "" as a value:oops: and not null, so when pasting it pastes the same 'value' and when moving across the sheet it behaves as if the cell had a content.

Do anybody know a work around?

Thanks
 
Private Sub Save_Click()
'Boton SAVE
'copia el resultado de todas las evaluaciones en la tab 'Results' debajo de la ultima entrada existente
Worksheets("summary").Range("H14:V36").Copy
Sheets("Results").Activate
Selection.End(xlToLeft).Select
Selection.End(xlDown).Select
Selection.End(xlDown).Select
Selection.End(xlUp).Select
ActiveCell.Offset(1).Select
Selection.PasteSpecial Paste:=xlPasteValues, Transpose:=True
Sheets("Summary").Activate
Application.CutCopyMode = False
End Sub
There is no need to hop around all over the place. Instead of activating sheets back and forth, you can simply reference them directly. All of the code above can be replaced by this (note my method for calculating the last row with data in it... it does not require Fluff's value=value trick).
Code:
[table="width: 500"]
[tr]
	[td]Private Sub Save_Click()
  Dim LastRow As Long
  Worksheets("summary").Range("H14:V36").Copy
  LastRow = Sheets("Results").Cells.Find("*", , xlValues, , xlRows, xlPrevious, , , False).Row
  Sheets("Results").Cells(LastRow + 1, "A").PasteSpecial Paste:=xlPasteValues, Transpose:=True
  Application.CutCopyMode = False
End Sub[/td]
[/tr]
[/table]
 
Upvote 0

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
@Rick
With your code, cells that had a formula returning "" still return false to =ISBLANK(B7)
 
Upvote 0

Forum statistics

Threads
1,215,219
Messages
6,123,689
Members
449,117
Latest member
Aaagu

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