GETTING DATA ON TO SHEET2

  • Thread starter Thread starter David McRitchie
  • Start date Start date
D

David McRitchie

Hi Tim,
Are you getting an error?
Did you record a macro, you don't need to make a selection,
and to process only one cell or even one column doesn't seem
to warrent a macro when you can use a worksheet function
to keep things up to data instantly.

Wouldn't simply putting a formula into Sheet2!d1 suffice?
=IF(sheet1!A1=0,,sheet1!A1)
 
Tim,

If Sheets("Sheet1").Range("A1")<>0 then
Sheets("Sheet2").Range("D1")=Sheets("Sheet1").Range("A1")
End If

This should work regardless of which sheet you are on.

regards,
Don
 
Hi,

- - - - - - - - - - - - - - - - - - - - - - - - - -
Sub ad_old() 'Your macro
If Range("Sheet1!A1") <> 0 Then
Range("Sheet2!D1").Select
Range("Sheet2!d1") = Range("Sheet1!a1")
End If
End Sub

Sub ad_new1()
If Range("Sheet1!A1") <> 0 Then
Worksheets("Sheet2").Select
Range("D1").Select
Range("Sheet2!d1") = Range("Sheet1!a1")
End If
End Sub

Sub ad_new2()
If Range("Sheet1!A1").Value <> 0 Then
Range("Sheet2!D1").Value = Range("Sheet1!A1").Value
End If
End Sub
- - - - - - - - - - - - - - - - - - - - - - - - - -


--
Regards,
Soo Cheon Jheong
_ _
^¢¯^
--
 
I am trying to get data in sheet1 a1 (10) into sheet 2 d1 and it wont run -
can you tell me where I am going wrong please?

Sub ad()
If Range("sheet1!a1") <> 0 Then
Range("sheet2!d1").Select
Range("sheet2!d1") = Range("sheet1!a1")
End If
End Sub
 
--
TIM LEE tax agent 55 807 001
4a/123 Colin St West Perth 6005
Tel 08 9481 0337 Fax 9321 0036
(e-mail address removed)
Soo Cheon Jheong said:
Hi,

- - - - - - - - - - - - - - - - - - - - - - - - - -
Sub ad_old() 'Your macro
If Range("Sheet1!A1") <> 0 Then
Range("Sheet2!D1").Select
Range("Sheet2!d1") = Range("Sheet1!a1")
End If
End Sub

Sub ad_new1() WITH THIS ONE
I GET A RUNTIME ERROR 1004

CAN YOU HELP PLEASE?
 
When I put this in it comes up in red - syntax error, but I have checked
carefully and retyped it twice - any idea what could be wrong - sheets are
indeed named sheet1 sheet2 and sheet3. Is that a reserved word [sheets]? I
am running mso2000 excel premium vers 9.0.2720
 
No Dave, I am trying to write a gen ledger program and it needs to be in vba
for other users to use by buttons on menu. I could do what you say but it
would be too slow and beyond the scope of the inputters. I understand what
you are saying 'keep it simple'
 
Looks like you were trying to mix syntax.

Sub copyover()
If Range("Sheet1!A1") <> 0 Then
Sheets("sheet2").Range("d1") = Sheets("sheet1").Range("a1")
'or
'[sheet2!d1] = [Sheet1!a1]
end if
End Sub

--
Don Guillett
SalesAid Software
(e-mail address removed)
tim lee said:
--
TIM LEE tax agent 55 807 001
4a/123 Colin St West Perth 6005
Tel 08 9481 0337 Fax 9321 0036
(e-mail address removed)
Soo Cheon Jheong said:
Hi,

- - - - - - - - - - - - - - - - - - - - - - - - - -
Sub ad_old() 'Your macro
If Range("Sheet1!A1") <> 0 Then
Range("Sheet2!D1").Select
Range("Sheet2!d1") = Range("Sheet1!a1")
End If
End Sub

Sub ad_new1() WITH THIS
ONE
I GET A RUNTIME ERROR 1004

CAN YOU HELP PLEASE?
 
Try copying mine or the other Don's instead of typing it. The syntax is
correct.

--
Don Guillett
SalesAid Software
(e-mail address removed)
tim lee said:
When I put this in it comes up in red - syntax error, but I have checked
carefully and retyped it twice - any idea what could be wrong - sheets are
indeed named sheet1 sheet2 and sheet3. Is that a reserved word [sheets]? I
am running mso2000 excel premium vers 9.0.2720

--
TIM LEE tax agent 55 807 001
4a/123 Colin St West Perth 6005
Tel 08 9481 0337 Fax 9321 0036
(e-mail address removed)
Don Lloyd said:
Tim,

If Sheets("Sheet1").Range("A1")<>0 then
Sheets("Sheet2").Range("D1")=Sheets("Sheet1").Range("A1")
End If

This should work regardless of which sheet you are on.

regards,
Don
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top