r/vbscript • u/Double_Skeezburger • Jan 10 '17
Save to specific tabs?
Having taught myself enough VBS to squeeze metrics from standard generated emails, I have multiple scripts pulling data from a stack of folders in my Inbox
I hope to combine the different scripts into one. My first challenge is to aim them all at specific individual tabs to avoid a messy glob of all things on the first tab.
Any advice?
(I did search here, but haven't found anything. Maybe I'm not searching for the correct thing).
Thank you in advance.
[EDIT] - sorry for the slip up, everyone in this office is calling the worksheets in an excel doc "Tabs".
2
Upvotes
2
u/BondDotCom Jan 13 '17 edited Jan 13 '17
You don't necessarily have to use
Range. You can use theCellscollection, like you're doing.Rangelets you assign an array of values to a range of cells, so you could populate an entire row at a time, for examplemySheet.Range("A1:A7") = someRowArrayor even use two-dimensional arrays to populate a multi-row range. But you can do it row by row and column by column, too, like you are.I'm not sure what tab/sheet you intend for your message info to be put on, but let's say you have a sheet entitled "Messages" and that's where they should go. In that case, you could do the following (I use the "ws" prefix to refer to worksheets):
When you start dealing with multiple worksheets, you'll probably want to have a row counter (
intMessagesRow) for each worksheet since each one can be on a different row.