$$Excel-Macros$$ Re: Introduce Yourself !!

2013-12-05 Thread Ricky Youngblood
Hello Everyone,

I am young  & dumb Figured i would start trying to look for more help 
than google.com offers. At first i was .. iffy about posting much but 
honestly felt retarded after seeing the great reply's i received. I have 2 
degrees that I hate and wish i had picked another path in life. Sound dumb 
but started just recording macros in excel and fell in love with the power 
of computers. Now do most all of my writing in VB net ,some C++.. . My work 
computer literately could turn on and do my job. My philosophy as should 
all is "Work smarter not harder". I am now starting to spread the wealth 
and helping my buddies at work and Excel has changed a bit.

Hope all is well to everyone & thank all for their help,

Ricky Youngblood  

On Friday, June 8, 2012 2:21:59 PM UTC-5, Ayush Jain wrote:
>
> Hey all new and current posters,
>  
> Welcome to excel group,one of the largest online community of excel Fans!
>  
> I hope you enjoy your time here & find this forum to be a friendly and 
> knowledgeable community. Please feel free to post a small introduction, a 
> friendly hello or tell us a bit about yourself. Why not tell us where are 
> you from, what you do, what your interests are, how old you are, which is 
> your favourite excel site or blog is or anything else that comes to mind!
>
> Thanks for your time
> Ayush Jain
> Group Manager
> Microsoft MVP
>

-- 
Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s 
=TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ 
https://www.facebook.com/discussexcel

FORUM RULES

1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
quick attention or may not be answered.
2) Don't post a question in the thread of another member.
3) Don't post questions regarding breaking or bypassing any security measure.
4) Acknowledge the responses you receive, good or bad.
5) Jobs posting is not allowed.
6) Sharing copyrighted material and their links is not allowed.

NOTE  : Don't ever post confidential data in a workbook. Forum owners and 
members are not responsible for any loss.
--- 
You received this message because you are subscribed to the Google Groups "MS 
EXCEL AND VBA MACROS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to excel-macros+unsubscr...@googlegroups.com.
To post to this group, send email to excel-macros@googlegroups.com.
Visit this group at http://groups.google.com/group/excel-macros.
For more options, visit https://groups.google.com/groups/opt_out.


$$Excel-Macros$$ Need Help - working code - but basic

2013-12-05 Thread Ricky Youngblood
Could someone write a somewhat dummy down version of looping and integers 
guide? Been learning Vba on the fly and the this code makes me sick. No 
need to do all the work. I rather just have the tools to learn and do 
myself. I have been Googling non-stop and have had no luck on finding 
something to help me understand them. 

*Sub Mapall_Click()*

*'//all Destinations String*
*Dim Start   As String*
*Dim Dst1As String*
*Dim Dst2As String*
*Dim Dst3As String*
*Dim Dst4As String*
*Dim Dst5As String*
*Dim Dst6As String*
*Dim Dst7As String*
*Dim Dst8As String*
*Dim Dst9As String*
*Dim Dst10   As String*
*Dim Dst11   As String*
*Dim Dst12   As String*
*Dim Dst13   As String*
*Dim Dst14   As String*
*Dim Dst15   As String*
*Dim Dst16   As String*
*Dim Dst17   As String*
*Dim Dst18   As String*
*Dim Dst19   As String*
*Dim Dst20   As String*
*Dim Dst21   As String*
*Dim Dst22   As String*
*Dim Dst23   As String*
*Dim FIN1As String*


*'//Set worksheet Google Map*
*Dim wsMAP  As Worksheet*
*Set wsMAP = Sheets("GOOGLE MAP")*

*'//Set worksheet Clients Routes*
*Dim wsRoute As Worksheet*
*Set wsRoute = Sheets("Routes")*

*'//all Destinations String*
*Start = wsRoute.Range("F6").Value '//Start*
*Dst1 = wsRoute.Range("F7").Value  '//Destination1*
*Dst2 = wsRoute.Range("F8").Value  '//Destination2*
*Dst3 = wsRoute.Range("F9").Value  '//Destination3*
*Dst4 = wsRoute.Range("F10").Value  '//Destination4*
*Dst5 = wsRoute.Range("F11").Value  '//Destination5*
*Dst6 = wsRoute.Range("F12").Value  '//Destination6*
*Dst7 = wsRoute.Range("F13").Value  '//Destination7*
*Dst8 = wsRoute.Range("F14").Value  '//Destination8*
*Dst9 = wsRoute.Range("F15").Value  '//Destination9*
*Dst10 = wsRoute.Range("F16").Value '//Destination10*
*Dst11 = wsRoute.Range("F17").Value '//Destination11*
*Dst12 = wsRoute.Range("F18").Value '//Destination12*
*Dst13 = wsRoute.Range("F19").Value '//Destination13*
*Dst14 = wsRoute.Range("F20").Value '//Destination14*
*Dst15 = wsRoute.Range("F21").Value '//Destination15*
*Dst16 = wsRoute.Range("F22").Value '//Destination16*
*Dst17 = wsRoute.Range("F23").Value '//Destination17*
*Dst18 = wsRoute.Range("F24").Value '//Destination18*
*Dst19 = wsRoute.Range("F25").Value '//Destination19*
*Dst20 = wsRoute.Range("F26").Value '//Destination20*
*Dst21 = wsRoute.Range("F27").Value '//Destination21*
*Dst22 = wsRoute.Range("F28").Value '//Destination22*
*Dst23 = wsRoute.Range("G28").Value '//Destination22*
*FIN1 = wsRoute.Range("F6").Value   '//Finish*

*Dim Urlstring   As String '//URL*
*On Error GoTo Out*

*'// Only 23 Destination*
* If wsRoute.Range("G28").Value = True Then*
 
*Urlstring = "http://maps.google.com/maps?q="; & Start & "+to:+" & Dst1 
& "+to:+" & Dst2 & "+to:+" _*
*& Dst3 & "+to:+" & Dst4 & "+to:+" & Dst5 & "+to:+" & Dst6 & "+to:+" _*
*& Dst7 & "+to:+" & Dst8 & "+to:+" & Dst9 & "+to:+" & Dst10 & "+to:+" _*
*& Dst11 & "+to:+" & Dst12 & "+to:+" & Dst13 & "+to:+" & Dst14 & 
"+to:+" _*
*& Dst15 & "+to:+" & Dst16 & "+to:+" & Dst17 & "+to:+" & Dst18 & 
"+to:+" _*
*& Dst19 & "+to:+" & Dst20 & "+to:+" & Dst21 & "+to:+" & Dst22 & 
"+to:+" _*
*& Dst23 & "+to:+" & FIN1 & "&output=embed&iwloc=near"*

*'MsgBox (Urlstring)*
 
* Else*
*'// Only 22 Destination*
* If wsRoute.Range("F28").Value = True Then*
 
*Urlstring = "http://maps.google.com/maps?q="; & Start & "+to:+" & Dst1 
& "+to:+" & Dst2 & "+to:+" _*
*& Dst3 & "+to:+" & Dst4 & "+to:+" & Dst5 & "+to:+" & Dst6 & "+to:+" _*
*& Dst7 & "+to:+" & Dst8 & "+to:+" & Dst9 & "+to:+" & Dst10 & "+to:+" _*
*& Dst11 & "+to:+" & Dst12 & "+to:+" & Dst13 & "+to:+" & Dst14 & 
"+to:+" _*
*& Dst15 & "+to:+" & Dst16 & "+to:+" & Dst17 & "+to:+" & Dst18 & 
"+to:+" _*
*& Dst19 & "+to:+" & Dst20 & "+to:+" & Dst21 & "+to:+" & Dst22 & 
"+to:+" _*
*& FIN1 & "&output=embed&iwloc=near"*

*'MsgBox (Urlstring)*
 
* Else*
* '// Only 21 Destination*
*If wsRoute.Range("F27").Value = True Then*
*Urlstring = "http://maps.google.com/maps?q="; & Start & "+to:+" & Dst1 
& "+to:+" & Dst2 & "+to:+" _*
*& Dst3 & "+to:+" & Dst4 & "+to:+" & Dst5 & "+to:+" & Dst6 & "+to:+" _*
*& Dst7 & "+to:+" & Dst8 & "+to:+" & Dst9 & "+to:+" & Dst10 & "+to:+" _*
*& Dst11 & "+to:+" & Dst12 & "+to:+" & Dst13 & "+to:+" & Dst14 & 
"+to:+" _*
*& Dst15 & "+to:+" & Dst16 & "+to:+" & Dst17 & "+to:+" & Dst18 & 
"+to:+" _*
*& Dst19 & "+to:+" & Dst20 & "+to:+" & Dst21 & "+to:+" _*
*& FIN1 & "&output=embed&iwloc=near"*

*'MsgBox (Urlstring)*

* Else*
* '// Only 20 Destination*
* If wsRoute.Range("F26").Value = True Then*
*Urlstring = "http://maps.google.com/maps?q="; & Start &

Re: $$Excel-Macros$$ Please help on FileName = Dir()

2013-12-05 Thread maksood alam
Hi Paul,

Thank you very much. It solved my query. [?]

Regard,
Maksood Alam
On Thu, Dec 5, 2013 at 5:59 PM, Paul Schreiner wrote:

>  In your script, you have a line:
>  FileName = Dir(CurrDir & "*.*", vbDirectory)
> This basically creates a "collection" of information from "CurrDir".
> vbDirectory indicates that it is to return "directories or folders in
> addition to files with no attributes".
>
> the statement itself returns the first entry in CurrDir.
>
> to loop through the rest of the entries in Currdir,
> you use Dir()
> So basically, Filename = Dir(CurrDir & "*.*",vbDirectory)
> gets the first entry,
> Filename = Dir()
> loops through the rest of the entries.
>
> BTW:  All this can be found using the VBA "help".
>
> hope this helps.
>
> *Paul*
> -
>
>
>
>
>
>
>
> *“Do all the good you can,By all the means you can,In all the ways you
> can,In all the places you can,At all the times you can,To all the people
> you can,As long as ever you can.” - John Wesley*
> -
>
>   *From:* maksood alam <786maks...@gmail.com>
> *To:* excel-macros@googlegroups.com
> *Sent:* Wednesday, December 4, 2013 2:05 PM
> *Subject:* $$Excel-Macros$$ Please help on FileName = Dir()
>
>  Hi Guys,
>
> Can anyone please explaint what  *FileName = Dir() *is doing in below
> code.
>
>
> Public Sub RecursiveDir(ByVal CurrDir As String, Optional ByVal Level As
> Long)
> Dim Dirs() As String
> Dim NumDirs As Long
> Dim FileName As String
> Dim PathAndName As String
> Dim i As Long
> Dim Filesize As Double
> ' Make sure path ends in backslash
> If Right(CurrDir, 1) <> "\" Then CurrDir = CurrDir & "\"
> ' Put column headings on active sheet
> Cells(1, 1) = "Path"""
> Cells(1, 2) = "Filename"""
> Cells(1, 3) = "Size"""
> Cells(1, 4) = "Date / Time"""
> Range("A1:D1").Font.Bold = True
> ' Get files
> FileName = Dir(CurrDir & "*.*", vbDirectory)
> Do While Len(FileName) <> 0
> If Left(FileName, 1) <> "." Then 'Current Dir
> PathAndName = CurrDir & FileName
> MsgBox (GetAttr(PathAndName) And vbDirectory)
> If (GetAttr(PathAndName) And vbDirectory) = vbDirectory Then
> 'store found directories
> ReDim Preserve Dirs(0 To NumDirs) As String
> Dirs(NumDirs) = PathAndName
> NumDirs = NumDirs + 1
> Else
> 'Write the path and file to the sheet
> Cells(WorksheetFunction.CountA(Range("A:A")) + 1, 1) = _
> CurrDir
> Cells(WorksheetFunction.CountA(Range("B:B")) + 1, 2) = _
> FileName
> 'adjust for filesize > 2 gigabytes
>Filesize = FileLen(PathAndName)
> If Filesize < 0 Then Filesize = Filesize + 4294967296#
> Cells(WorksheetFunction.CountA(Range("C:C")) + 1, 3) =
> Filesize
> Cells(WorksheetFunction.CountA(Range("D:D")) + 1, 4) = _
> FileDateTime(PathAndName)
> End If
> End If
>
> *FileName = Dir()*Loop
> ' Process the found directories, recursively
> For i = 0 To NumDirs - 1
> RecursiveDir Dirs(i), Level + 2
> Next i
> End Sub
>
>
>
>
> Thanks,
> Maksood Alam
> --
> Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s
> =TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @
> https://www.facebook.com/discussexcel
>
> FORUM RULES
>
> 1) Use concise, accurate thread titles. Poor thread titles, like Please
> Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice
> will not get quick attention or may not be answered.
> 2) Don't post a question in the thread of another member.
> 3) Don't post questions regarding breaking or bypassing any security
> measure.
> 4) Acknowledge the responses you receive, good or bad.
> 5) Jobs posting is not allowed.
> 6) Sharing copyrighted material and their links is not allowed.
>
> NOTE : Don't ever post confidential data in a workbook. Forum owners and
> members are not responsible for any loss.
> ---
> You received this message because you are subscribed to the Google Groups
> "MS EXCEL AND VBA MACROS" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to excel-macros+unsubscr...@googlegroups.com.
> To post to this group, send email to excel-macros@googlegroups.com.
> Visit this group at http://groups.google.com/group/excel-macros.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>  --
> Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s
> =TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @
> https://www.facebook.com/discussexcel
>
> FORUM RULES
>
> 1) Use concise, accurate thread titles. Poor thread titles, like Please
> Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice
> will not get quick attention or may not be answered.
> 2) Don't post a question in the thread of another member.
> 3) Don't post questions regarding breaking or bypassing any security
> measure.
> 4) Acknowledge the responses y

Re: $$Excel-Macros$$ Please help on FileName = Dir()

2013-12-05 Thread Paul Schreiner
In your script, you have a line:
FileName = Dir(CurrDir & "*.*", vbDirectory)
This basically creates a "collection" of information from "CurrDir".
vbDirectory indicates that it is to return "directories or folders in addition 
to files with no attributes".
 
the statement itself returns the first entry in CurrDir.
 
to loop through the rest of the entries in Currdir,
you use Dir()
So basically, Filename = Dir(CurrDir & "*.*",vbDirectory)
gets the first entry,
Filename = Dir() 
loops through the rest of the entries.
 
BTW:  All this can be found using the VBA "help".
 
hope this helps.

Paul
-
“Do all the good you can,
By all the means you can,
In all the ways you can,
In all the places you can,
At all the times you can,
To all the people you can,
As long as ever you can.” - John Wesley
-


>
> From: maksood alam <786maks...@gmail.com>
>To: excel-macros@googlegroups.com 
>Sent: Wednesday, December 4, 2013 2:05 PM
>Subject: $$Excel-Macros$$ Please help on FileName = Dir()
>  
>
>
>Hi Guys, 
>
>Can anyone please explaint what  FileName = Dir() is doing in below code. 
>
>
>Public Sub RecursiveDir(ByVal CurrDir As String, Optional ByVal Level As Long)
>Dim Dirs() As String
>Dim NumDirs As Long
>Dim FileName As String
>Dim PathAndName As String
>Dim i As Long
>Dim Filesize As Double
>' Make sure path ends in backslash
>If Right(CurrDir, 1) <> "\" Then CurrDir = CurrDir & "\"
>' Put column headings on active sheet
>Cells(1, 1) = "Path"""
>Cells(1, 2) = "Filename"""
>Cells(1, 3) = "Size"""
>Cells(1, 4) = "Date / Time"""
>Range("A1:D1").Font.Bold = True
>' Get files
>FileName = Dir(CurrDir & "*.*", vbDirectory)
>Do While Len(FileName) <> 0
>If Left(FileName, 1) <> "." Then 'Current Dir
>    PathAndName = CurrDir & FileName
>    MsgBox (GetAttr(PathAndName) And vbDirectory)
>    If (GetAttr(PathAndName) And vbDirectory) = vbDirectory Then
>'store found directories
>    ReDim Preserve Dirs(0 To NumDirs) As String
>    Dirs(NumDirs) = PathAndName
>    NumDirs = NumDirs + 1
>    Else
>'Write the path and file to the sheet
>    Cells(WorksheetFunction.CountA(Range("A:A")) + 1, 1) = _
>    CurrDir
>    Cells(WorksheetFunction.CountA(Range("B:B")) + 1, 2) = _
>    FileName
>'adjust for filesize > 2 gigabytes
>   Filesize = FileLen(PathAndName)
>    If Filesize < 0 Then Filesize = Filesize + 4294967296#
>    Cells(WorksheetFunction.CountA(Range("C:C")) + 1, 3) = Filesize
>    Cells(WorksheetFunction.CountA(Range("D:D")) + 1, 4) = _
>    FileDateTime(PathAndName)
>    End If
>    End If
>FileName = Dir()
>Loop
>' Process the found directories, recursively
>For i = 0 To NumDirs - 1
>RecursiveDir Dirs(i), Level + 2
>Next i
>End Sub 
>
>
>
>
>Thanks, 
>Maksood Alam
-- 
>Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s 
>=TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ 
>https://www.facebook.com/discussexcel
> 
>FORUM RULES
> 
>1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
>Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
>quick attention or may not be answered.
>2) Don't post a question in the thread of another member.
>3) Don't post questions regarding breaking or bypassing any security measure.
>4) Acknowledge the responses you receive, good or bad.
>5) Jobs posting is not allowed.
>6) Sharing copyrighted material and their links is not allowed.
> 
>NOTE  : Don't ever post confidential data in a workbook. Forum owners and 
>members are not responsible for any loss.
>--- 
>You received this message because you are subscribed to the Google Groups "MS 
>EXCEL AND VBA MACROS" group.
>To unsubscribe from this group and stop receiving emails from it, send an 
>email to excel-macros+unsubscr...@googlegroups.com.
>To post to this group, send email to excel-macros@googlegroups.com.
>Visit this group at http://groups.google.com/group/excel-macros.
>For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s 
=TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ 
https://www.facebook.com/discussexcel

FORUM RULES

1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
quick attention or may not be answered.
2) Don't post a question in the thread of another member.
3) Don't post questions regarding breaking or bypassing any security measure.
4) Acknowledge the responses you receive, good or bad.
5) Jobs posting is not allowed.
6) Sharing copyrighted material and their links is not allowed.

NOTE  : Don't ever post confidential data in a workbook. Forum owners and 
members are not responsible for any loss.
---

$$Excel-Macros$$ VBA macro to replace Index and Match formula

2013-12-05 Thread ncliew
 

Hello, I'm new here and need some help.

I need to perform stock analysis regularly, which involves the use of files 
with data in multiple columns and more than 100K lines of records.  

To provide a better illustration of the routine tasks I perform, I've 
attached a file for simulation purpose.

Let’s assume that one of the regular reports that I prepare is the one that 
summarise the stock info as shown in the worksheet titled “Report”.  To 
prepare the report, I sort the data in the worksheet “Data” and then use 
Index and Match formula to extract the data (based on the conditions shown 
in the formula).

In this example, the table in the “Report” summarises the stock info by 
company, item and stock location.  However, not all records in the 
worksheet “Data” will be extracted to this report.  In fact, only the top 
six (in terms of stock value) records that match the criteria will be 
extracted.  

For example, there are 14 records found in the worksheet “Data” that match 
the conditions “Item A”, “Store 1” and “ABC”.  As a result of the "top six" 
rule, only the six records with highest stock value are displayed in the 
“Report”.  Likewise, only 2 records are found in the worksheet “Data” that 
match the conditions “Item A”, “Store 3” and “ABC”.   All the two are 
extracted and displayed in the “Report”.

The number of lines to be shown in the “Report” is fixed i.e. if the number 
of records found with the matching criteria is less than 6, “NA” will be 
displayed in the “extra” lines (as displayed in the “Report” for item A 
stored in “Store 3” and owned by “ABC”.

I hope someone could show me how to create a macro that would replace the 
Index and Match formula.  The current method of using the Index and Match 
formula is just not that efficient, especially when there are thousand of 
stock items that need to be analysed.

-- 
Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s 
=TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ 
https://www.facebook.com/discussexcel

FORUM RULES

1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
quick attention or may not be answered.
2) Don't post a question in the thread of another member.
3) Don't post questions regarding breaking or bypassing any security measure.
4) Acknowledge the responses you receive, good or bad.
5) Jobs posting is not allowed.
6) Sharing copyrighted material and their links is not allowed.

NOTE  : Don't ever post confidential data in a workbook. Forum owners and 
members are not responsible for any loss.
--- 
You received this message because you are subscribed to the Google Groups "MS 
EXCEL AND VBA MACROS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to excel-macros+unsubscr...@googlegroups.com.
To post to this group, send email to excel-macros@googlegroups.com.
Visit this group at http://groups.google.com/group/excel-macros.
For more options, visit https://groups.google.com/groups/opt_out.


Extract Stock Data.xlsx
Description: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet