copy SheetCell

dy

New Member
Joined
Jun 16, 2004
Messages
19
Can anyone tell me what I did wrong here?
I do not get any error message, but I can't get Sheets(i).Range("B1") to copy over to Sheets(35). Thanks!

Sub ProcedureA()

Dim i As Integer

For i = 1 To 34
If Sheets(35).Range("C2") = Sheets(i).Range("A1") Then
Sheets(35).Range("C3") = Sheets(i).Range("B1")

End If
Next i

End Sub
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Are you sure of what you're really doing ?

try this: it's your macro with some text to clarify what's happening
kind regards,
Erik

Code:
Sub ProcedureA()

Dim i As Integer

For i = 1 To 34
MsgBox "if Range(""C1"") with value " & """" & Sheets(35).Range("C1") & """" & _
" on sheets(35) which is called " & """" & Sheets(35).Name & """" & Chr(10) & _
"equals to Range(""A1"") with value " & """" & Sheets(i).Range("A1") & """" & _
" on Sheets(i) (i = " & i & ") which is now " & """" & Sheets(i).Name & """" & Chr(10) & _
" then Sheets(35).Range(""C3"") will get the value from Sheets(i).Range(""B1"")" & _
"which is " & """" & Sheets(i).Range("B1") & """"

If Sheets(35).Range("C2") = Sheets(i).Range("A1") Then
Sheets(35).Range("C3") = Sheets(i).Range("B1")
End If
Next i
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,980
Messages
6,122,563
Members
449,088
Latest member
Motoracer88

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