*VBA Experts Needed* Troubleshoot Code

NicoleJ1987

New Member
Joined
Apr 12, 2012
Messages
3
Please help! I am very much a beginner! I am trying to write a code that retrieves information from this sheet entitled "Upload":

A, B, C, D
North America, Florida, Population, 938397.02
North America, Florida, Temperature, 85.04
Africa, Ghana, Population, 829783.50
Africa, Ghana, Temperature, 99.02
North America, Florida, Temperature, 99.20

I want to be able to use VBA to scan the Upload sheet, first for continent (e.g. "North America") - if true - then for State (e.g. "Florida") on the same row - if true - then for "Temperature" on the same row and if that's true also, retrieve number (in this case 99.02) and place it in the sheet entitled "Region" in C3. Also, if there are multiple lines, to sum them.

This is what I pulled together so far, which returns an error of "Compile Error, For without next".

Sub Oval1_Click()


For Each ResultCell In ResultRange

Worksheets("Upload").Activate

Cells.Find(What:="Africa", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False).Select

If (ActiveCell.Offset(0, 1).Value) = "Ghana" And (ActiveCell.Offset(0, 2).Value) = "Population" Then
ActiveCell.Offset(0, 3).Select
ActiveCell.Copy
Worksheets("Region").Cell("B3").Paste
Application.CutCopyMode = False
End If

End Sub

C:\Users\Nicole Johnson\Desktop\untitled7.png
 

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