Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Binge Fischer   on Oct 24 In MS Office Category.

  
Question Answered By: Clay Cook   on Oct 24

OK, Random thought-wise..
Option Explicit: In effect, this says that you're selecting the "option" that
all variables must be "explicit"ly dimensioned.
This is a valuable option, since, without it, VBA will "automatically" dimension
a variable the first time it is used.
That means that if you say:
cnt = 10
than later say:
cnt = cont + 1 but MEANT cnt = cnt + 1
cnt is NOT 11, but 1. Because you haven't defined "cont", VBA defined it for
you and initialized it to 0. If you use option  Explicit, the compiler will give
you an error and tell you that "cont" is not defined.

Private Sub just means that the subroutine is not available outside of this
workbook. This is useful if you tend to use the same subroutine names in
different files, and you want to make sure you're running the right sub.

Neither of these will "preclude" you from using a keyboard  shortcut.

Next, I noticed that in the .Open function, you're using:
Stops\" & ticker & "/" & bdate & ".csv"
This POTENITALLY could cause a problem with the "forward" slash ("/") instead of
the "backward" slash ("\")

Now, in the "B" column, will the dates  have any "blank" values?
That is, if you were to count the non-blank cells between B6 and B65000,
and, say, there is 10 dates, can you count on these 10 to be in rows 6 through
15 with no blank cells?

If so, you can count the dates using a worksheet function:

datecnt = Application.worksheetfunction.counta(range("B6:B" & 65000)

Then use:
set DateRange = Sheets("Sheet1").Range("B6:B" & datecnt + 6)
for each Data in daterange.columns(1).cells
bdate = data.value
' Use your code here
next Data


Now, using these tools, try your hand at creating a "tickercnt"
and set TickRange = "range of tickers"

Share: 

 

This Question has 2 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on Help with "Nested Do While Loop" Or get search suggestion and latest updates.


Tagged: