Run time error 424

dracula

New Member
Joined
Feb 14, 2014
Messages
1
I have a very basic code to copy "non-blank" data from one sheet and paste to another. The code is not complete yet - I am running in debug mode I get the above error. My code is as below.

Sub SampleFind()
Dim StrWord As String
Dim Quantity As String
Dim i As Long

Call nrows

For j = 2 To 2
For i = 2 To nrows1

StrWord = Sheets("Sheet6").Cells(i, 1).Value
Quantity = Sheets("Sheet6").Cells(i, j).Value

If (Quantity = "") Then
Else
Cells(i, 1).Value.Copy Destination:=Sheets("Sheet8").Cells(i, j) - I get the error when debugging at this location
End If


Next i
Next j
End sub
 

Momentman

Well-known Member
Joined
Jan 11, 2012
Messages
3,963
Have you tried

Rich (BB code):
Sheets("SheetX").Cells(i, 1).Copy Sheets("Sheet8").Cells(i, j)
 

AngelJ

Board Regular
Joined
Jan 8, 2013
Messages
226
Have you tried

Rich (BB code):
Sheets("SheetX").Cells(i, 1).Copy Sheets("Sheet8").Cells(i, j)
Your code will work but the highlighted portion is a bit misleading. The Value part was the problem:
Rich (BB code):
Cells(i, 1).Value.Copy Destination:=Sheets("Sheet8").Cells(i, j)

 

Momentman

Well-known Member
Joined
Jan 11, 2012
Messages
3,963
Your code will work but the highlighted portion is a bit misleading. The Value part was the problem:
Apologies for that. If that sheet isn't the active worksheet, then he would be copying the from the wrong sheet/cell, hence my adding the sheet name so the code picks up the correct cell.
 

AngelJ

Board Regular
Joined
Jan 8, 2013
Messages
226
Apologies for that. If that sheet isn't the active worksheet, then he would be copying the from the wrong sheet/cell, hence my adding the sheet name so the code picks up the correct cell.
No problem! That makes sense. The red text just made it seem like that was the solution to the run time error.
 

Forum statistics

Threads
1,082,280
Messages
5,364,210
Members
400,786
Latest member
ismi88

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top