Code Help!!

asdaftasabrush

New Member
Joined
Feb 1, 2017
Messages
8
Anyone know why this line of code is failing?


Private Sub GenerateRedsNights_Click()
Sheets("Red Alerts").Range("A5:M500").ClearContents
If Sheets("General Areas Sauce").Cells("D20:D59").Value = "R" Then
Sheets("General Areas Sauce").Cells("G20:G59").cellcopy Destination:=Sheets("Red Alerts").Range("F5" & Rows.Count).Offset(1)
End If
End Sub
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
There are several things wrong with this script. Why not tell us what your wanting to do.
 
Upvote 0
Thank you for getting back to me. This is my third thread for the same task simplifying each time.
I need cells D20:D59 on the first sheet to have an "R" in them (manually input). When they score this, reasons for the score go into G20:G59. So if an R goes into cell D37 then the data in G37 needs to be copied onto another sheet starting at F5 (and any other data from other Reds as they're called in this case need to be copied in the cells below in a continuous fashion.)

I know I'm over complicating it, but I hope you can make sense of it and help. :)
 
Upvote 0
Will try to help

What does this mean:
Your quote " needs to be copied onto another sheet"
You need to give specific details like copied to sheet named "Score"

And what does this mean:
Your quote:
"and any other data from other Reds as they're called in this case need to be copied in the cells below in a continuous fashion.)

I do not understand any of this. From other Reds??? Do you mean below F5 in your "Other sheet"
Is other Reds the values in Master sheet that will be manually entered?

Please always give details we would understand. How would I be expected to know what other Reds would mean?

And I need the name of both sheets.
And when you say:
I need cells D20:D59 on the first sheet to have an "R" in them (manually input).

You mean your users will input this data and when they do you want this to copy over to other sheet automatically.
 
Upvote 0
Right, let me start again.

Below is an example sheet.

TinyUpload.com - best file hosting solution, with no limits, totaly free

Operators will manually place an "R","A" or "G" in cells (again, please refer to the document) and when an "R" is placed, they put an explanation in the cell marked "issue". The data from the issue cell is the data I need copying and pasting into another tab (in this example, "Report") So once all of the issues are entered, one button is pressed and all of the issues are pasted into the next tab.

I believe the sheet is probably clearer than my explanation.

Please ignore the photo section for now. Thanks.
 
Upvote 0
You said previously you have attempted to get answers to your request before with no success.
It may be because you are not giving specific details.
And I never click on links posted in this forum.
If your not able to provide details in writing then I'm not able to help you.

Here are some of your non specific details:

Operators will manually place an "R","A" or "G" in cells What cells?

when an "R" is placed, they put an explanation in the cell marked "issue" What cell is marked "issue"

I need copying and pasting into another tab (in this example, "Report") Paste where into another tab



 
Upvote 0
If any cells on "Sheet 1" from B2 to B4 contain a letter "R" then the data from E2 to E4 needs to be copied...

vc1s6.jpg


...then placed onto "Sheet 2" starting at A2 and following on below.

1y7681.jpg
 
Upvote 0
So why not simply use a formula on Sheet2

Code:
=IF(Sheet1!E2="","",Sheet1!E2)
If there are a lot of blanks, filter them out with autofilter !!
 
Upvote 0
Because comments are also filled out if the "A" category is completed. Plus there's nearly 50 categories on the actual document. That would be a long formula wouldn't it?
 
Upvote 0
As MAIT has already mentioned.....I'm not going to download a workbook....not many will !!
But the formula I provided earlier will do what you wanted if pasted in Sheet2 cell A1 and dragged down as required.

IF you want a macro....

Code:
Sub MM1()
Dim lr As Long, r As Long, lr2 As Long
lr = Cells(Rows.Count, "A").End(xlUp).Row
lr2 = Sheets("Report").Cells(Rows.Count, "A").End(xlUp).Row
For r = 1 To lr
    If Range("E" & r).Value <> "" Then
       Range("E" & r).Copy Sheets("Report").Range("A" & lr2)
        lr2 = Sheets("Report").Cells(Rows.Count, "A").End(xlUp).Row + 1
    End If
Next r
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,270
Messages
6,171,103
Members
452,379
Latest member
IainTru

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