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
 

Some videos you may like

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.

erik.van.geit

MrExcel MVP
Joined
Feb 1, 2003
Messages
17,832
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
 

Watch MrExcel Video

Forum statistics

Threads
1,123,514
Messages
5,602,087
Members
414,501
Latest member
mdhaumyu

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
Top