LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default variable trouble


I guess I don't know the proper way to reference variables in code..
can anyone troubleshoot this routine for me? GREATLY appreciated...
get errors almost every time I try to use a variable in code. fo
example,
Workbooks(fname).Activate gives me an error. If I eliminate this cod
by just activating a specific workbook instead of the one defined b
fname, I get an error somewhere else where I tried to use a variable
like at
Set destCell = destWks.Cells(3, dcol) where VB says I didn't define th
variable yet.

Sub get1degdata()
'
' get1degdata Macro
' Macro recorded 11/19/2004 by Kieran Coghlan
'
'
Dim ramp As Variant
Dim toes As Variant
Dim fname As Variant
Dim Wkbk As Workbook
Dim wksht As Worksheet
Dim destWks As Worksheet
Dim destCell As Range
Dim dcol As Integer
fname = Application.GetOpenFilename("Excel files(*.xls),*.xls")
Workbooks.Open (fname)
Workbooks(fname).Activate
' Sheets("charts").Select
Set Wkbk = Workbooks(fname)
ramp = InputBox("Enter the ramp duration in ms: 500, 1000, 2000, o
4000")
toes = InputBox("Enter the toes direction, UP or DOWN")
Sheets.Add.Name = ramp
Worksheets(ramp).Select
dcol = 1
For Each wksht In Wkbk.Worksheets
If wksht.Range("K5") = ramp And wksht.Range("G7") = toes Then
Set destWks = Wkbk.Worksheets(ramp)
wksht.Range("q12:q2011").Copy
End If
Set destCell = destWks.Cells(3, dcol)
destCell.PasteSpecial Paste:=xlPasteValues, Operation _
:=xlNone, SkipBlanks:=False, Transpose:=False
dcol = dcol + 1
Next
End Sub

Thanks,
Kiera

--
Kieran102
-----------------------------------------------------------------------
Kieran1028's Profile: http://www.excelforum.com/member.php...fo&userid=1567
View this thread: http://www.excelforum.com/showthread.php?threadid=31936

 
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
Having trouble getting MATCH to work with a variable lookup array Chuck M Excel Worksheet Functions 3 August 20th 08 11:45 PM
why is it saying sheetcnt is "variable not defined" how to do a global variable to share over multiple functions in vba for excel? Daniel Excel Worksheet Functions 1 July 9th 05 03:05 AM
Trouble with variable type Ken McLennan[_3_] Excel Programming 2 June 2nd 04 08:04 AM
Cells.Find error Object variable or With block variable not set Peter[_21_] Excel Programming 2 May 8th 04 02:15 PM
Trouble setting variable as filename with date Elby Excel Programming 2 February 21st 04 03:05 PM


All times are GMT +1. The time now is 03:43 AM.

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"