How to run this macro

P

Paul Lambson

I am trying to run this macro to take the value in cells C1 & C2 and
write them in the cells below. When I run this macro nothing happens.
What am i missing?

Sub LegUpdate()
'
Dim ORG As String
Dim DES As String

ORG = c1
DES = c2

B5 = ORG
H5 = ORG
N5 = ORG

B29 = ORG
H29 = ORG
N29 = ORG

B6 = DES
H6 = DES
N6 = DES

B28 = DES
H28 = DES
N26 = DES
'

'
End Sub
 
R

Rick Rothstein

What are c1 and c2... cell addresses? If so, try this...

ORG = Range("C1").Value
DES = Range("C2").Value
 
J

john

your code does not reference any worksheet / range

see if this does what you want.

Sub LegUpdate()
'
Dim ORG As String
Dim DES As String
Dim Myws As Worksheet

Set Myws = Worksheets("Sheet1") '<< change as required

With Myws

ORG = .Range("c1").Value
DES = .Range("c2").Value

.Range("B5,B29,H5,H29,N5,N29") = ORG


.Range("B6,B28,H6,H28,N6,N28") = DES

End With

End Sub
 
S

Sam

What are c1 and c2... cell addresses? If so, try this...

ORG = Range("C1").Value
DES = Range("C2").Value

--
Rick (MVP - Excel)













- Show quoted text -

Rick has the right idea (i.e. DES = Range("C2").Value ). I would just
add that to set the value you must use Range or Cells.

Range("B5") = ORG

also if you want to reference a specific sheet you can do that as
well.

Sheets("sheet_name").Range("B5") = ORG

Good luck,

Sam
 
R

Rick Rothstein

LOL... I was concentrating so hard on the c1/c2 problem that I completely
overlooked the rest of the code's problems. Thanks for catching that.

--
Rick (MVP - Excel)


What are c1 and c2... cell addresses? If so, try this...

ORG = Range("C1").Value
DES = Range("C2").Value

--
Rick (MVP - Excel)













- Show quoted text -

Rick has the right idea (i.e. DES = Range("C2").Value ). I would just
add that to set the value you must use Range or Cells.

Range("B5") = ORG

also if you want to reference a specific sheet you can do that as
well.

Sheets("sheet_name").Range("B5") = ORG

Good luck,

Sam
 

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

Top