Copy Non Blank Cells

howard

Well-known Member
Joined
Jun 26, 2006
Messages
6,570
Office Version
  1. 2021
Platform
  1. Windows
I have a formula in Col H as follows:


Code:
=IF(OR(C2=1,C2=-1),B2/0.14,"")


I have tried to write code to copy the non-blank values in Col H and paste these as values in Col C


I get a run time error "Application defined or object-defined eerror"

The code below is highlighted

It would be appreciated if someone could kindly amend my code



Code:
  .Range(.Cells(i, 8)).Copy

Code:
 Sub copyNonBlankData()
 Dim LR As Long, i As Long


LR = Sheets(3).Cells(Rows.Count, 1).End(xlUp).Row


For i = 2 To LR
 If Sheets(3).Cells(i, 8) <> “” Then
 With Sheets(3)
 .Range(.Cells(i, 8)).Copy
 .Range(.Cells(i, 3)).PasteSpecial xlPasteValues
   End With
   
 
 End If
 Next i


Application.CutCopyMode = False


End Sub
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Thanks for the help. Code works perfectly
 
Upvote 0
Another option
Code:
Sub chk()
With Range("H:H").SpecialCells(xlFormulas, xlNumbers)
   .Offset(, -5).Value = .Value
End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,216,071
Messages
6,128,619
Members
449,460
Latest member
jgharbawi

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