Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default How to run this macro

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default How to run this macro

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

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

--
Rick (MVP - Excel)


"Paul Lambson" wrote in message
...
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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,069
Default How to run this macro

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
--
jb


"Paul Lambson" wrote:

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


  #4   Report Post  
Posted to microsoft.public.excel.programming
Sam Sam is offline
external usenet poster
 
Posts: 1
Default How to run this macro

On May 27, 2:32*pm, "Rick Rothstein"
wrote:
What are c1 and c2... cell addresses? If so, try this...

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

--
Rick (MVP - Excel)

"Paul Lambson" wrote in message

...



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- Hide quoted text -


- 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
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default How to run this macro

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)


"Sam" wrote in message
...
On May 27, 2:32 pm, "Rick Rothstein"
wrote:
What are c1 and c2... cell addresses? If so, try this...

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

--
Rick (MVP - Excel)

"Paul Lambson" wrote in message

...



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- Hide quoted text -


- 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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro recorded... tabs & file names changed, macro hangs Steve Excel Worksheet Functions 3 October 30th 09 11:41 AM
AutoRun Macro with a delay to give user the choice to cancel the macro wanderlust Excel Programming 2 September 28th 07 04:09 PM
Need syntax for RUNning a Word macro with an argument, called from an Excel macro Steve[_84_] Excel Programming 3 July 6th 06 07:42 PM
macro to delete entire rows when column A is blank ...a quick macro vikram Excel Programming 4 May 3rd 04 08:45 PM
Start Macro / Stop Macro / Restart Macro Pete[_13_] Excel Programming 2 November 21st 03 05:04 PM


All times are GMT +1. The time now is 07:01 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"