|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||||
|
|||||
|
Excel Macro Code Help
Hi there,
I'm trying to make a very simple excel macro but I'm struggling with range variables. This is the code i'm using: vb Code:
but that doesn't work. where am i going wrong? Moderator's Note: Syntax highlighting added by Nilpo Last edited by Nilpo : July 16th, 2009 at 08:28 AM. |
|
#2
|
||||
|
||||
|
--> Moved to VB Forum
Hi, I've not had any experience with this but I would imagine that you need to concatenate your values in some way, try something like this: Code:
Range(Rone & ":" & Rtwo).Select Or you may need to surround the values with double quotes: Code:
Range(""" & Rone & ":" & Rtwo & """).Select
|
|
#3
|
|||
|
|||
|
Yes, you will need to concatenate. Here are some examples of using the Range, Cells, Columns objects/properties:
This one uses Range with a variable for the bottom row of range Code:
'Sort records on Results sheet so they will be in Date then Point then LabNum order for the GEOReport
Worksheets("Results").Range("3:" & intResults + 2).Sort _
Key1:=Worksheets("Results").Range("AO3"), Order1:=xlAscending, _
Key2:=Worksheets("Results").Range("A3"), Order2:=xlAscending, _
Key3:=Worksheets("Results").Range("B3"), Order3:=xlAscending, _
Header:=xlNo, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal, DataOption2:=xlSortNormal, DataOption3:=xlSortNormal
Code:
With Worksheets("Results")
.Cells(intNCount, 1).Value = rsData.Fields("SampledFrom")
.... about 40 similar lines
End With
Code:
xlApp.Worksheets("Sheet1").Columns("B").ColumnWidth = 12
Last edited by June7 : July 16th, 2009 at 04:29 AM. |
|
#4
|
||||
|
||||
|
Thread moved to Windows Scripting.
__________________
Scripting problems? Windows questions? Ask the Windows Guru! Stay up to date with all of my latest content. Follow me on Twitter! Help us help you! Post your exact error message with these easy tips! |
![]() |
| Viewing: ASP Free Forums > System Administration > Windows Scripting > Excel Macro Code Help |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|