$$Excel-Macros$$ Re: Need help to select the data columns into pivot table data field using VBA code.....
Hi Mathan, I used column A to determine the number of rows that should be included in the pivottable range. And I used Row 1 to determine the number of columns. I assume that the headers are all nicely valid--no duplicates and no blanks, right. And that you want Sum for each of those other fields. Option Explicit Sub Pivot_Table() Dim myRng As Range Dim LastRow As Long Dim FirstCol As Long Dim LastCol As Long Dim iCol As Long Dim RowFieldArray() As String Dim DataFieldArray() As String Dim wks As Worksheet Set wks = Worksheets("Data") With wks .Activate LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row FirstCol = 3 'skipping columns A and B LastCol = .Cells(1, .Columns.Count).End(xlToLeft).Column Set myRng = .Range("A1", .Cells(LastRow, LastCol)) ReDim RowFieldArray(1 To 3) RowFieldArray(1) = .Range("a1").Value RowFieldArray(2) = .Range("b1").Value RowFieldArray(3) = "Data" ReDim DataFieldArray(3 To LastCol) For iCol = 3 To LastCol DataFieldArray(iCol) = .Cells(1, iCol).Value Next iCol .Parent.PivotCaches.Add(SourceType:=xlDatabase, _ SourceData:=myRng.Address(external:=True)).CreatePivotTable _ TableDestination:="", _ TableName:="PT" & Format(Now, "mmdd_hhmmss"), _ DefaultVersion:=xlPivotTableVersion10 End With With ActiveSheet .PivotTableWizard TableDestination:=.Range("A3") .PivotTables(1).AddFields RowFields:=RowFieldArray For iCol = 3 To LastCol With .PivotTables(1).PivotFields(iCol) .Orientation = xlDataField .Position = iCol - 2 .Function = xlSum End With Next iCol With .PivotTables(1).DataPivotField .Orientation = xlColumnField .Position = 1 End With .UsedRange.Columns.AutoFit .Range("a1").Select 'just to make sure it's visible .Range("C5").Select ActiveWindow.FreezePanes = True End With End Sub Regards, Vallinayagam On Dec 9, 3:59 pm, Mathan wrote: > Dear All, > > Could you please help me out in this? > > In attached file I need to select all the data from column "C" to "Y" into > data field in pivot table using VBA code. > > It is very hard to drag all the items. e.g.) If we have more > than 100 coulmns. > > Thanks in advance for your quick reply. > > Regards, > Mathan > > Pivot.xls > 211KViewDownload -- -- Some important links for excel users: 1. Excel and VBA Tutorials(Video and Text), Free add-ins downloads at http://www.excelitems.com 2. Excel tutorials at http://www.excel-macros.blogspot.com 3. Learn VBA Macros at http://www.vbamacros.blogspot.com 4. Excel Tips and Tricks at http://exceldailytip.blogspot.com To post to this group, send email to excel-macros@googlegroups.com If you find any spam message in the group, please send an email to: Ayush Jain @ jainayus...@gmail.com or Ashish Jain @ 26may.1...@gmail.com <><><><><><><><><><><><><><><><><><><><><><> HELP US GROW !! We reach over 6,500 subscribers worldwide and receive many nice notes about the learning and support from the group. Our goal is to have 10,000 subscribers by the end of 2009. Let friends and co-workers know they can subscribe to group at http://groups.google.com/group/excel-macros/subscribe
Re: $$Excel-Macros$$ Extracting Numbers from the Text
Hi Selva, Step 1: Separte the numbers using Text to column using "Space" as delimiter Step 2: Select Edit\Go to\ and click special and select constants and unselct the check box Numbers below the formulas options Step 3: Delete the selected cells You have got only the numbers, but in different column. Write a sum function in the last column. I hope this will help you. Regards, Vallinayagam On Dec 22, 9:07 am, Mahesh wrote: > Hi Selva, > > Which version of MS Excel u r using? > > Use ASAP utilities. > > 1. Click on Text--->Delete all characters in the selceted cell. > > U will get all the employee No. > > attached is the sample > > On Mon, Dec 21, 2009 at 11:54 PM, Paul Schreiner > wrote: > > > > > > > Selva, > > I couldn't find a simple way to "find" the numbers > > using standard Excel functions, so > > I created a function called Get_Number() > > It will extract only the numbers from the string. > > > take a look. > > > Public Function Get_Number(Str) > > Dim I, NumStr > > NumStr = "" > > For I = 1 To Len(Str) > > If (IsNumeric(Mid(Str, I, 1))) Then > > NumStr = NumStr & Mid(Str, I, 1) > > End If > > Next I > > Get_Number = NumStr > > End Function > > > paul > > > -- > > *From:* selva jayapal > > *To:* excel-macros@googlegroups.com > > *Sent:* Mon, December 21, 2009 11:56:32 AM > > *Subject:* $$Excel-Macros$$ Extracting Numbers from the Text > > > Dear All Excel Gurus, > > > This is my first mail to this group. I have read many mails from this group > > which is of great useful to me. > > > Currently I am finding a problem in extracting the employee no from the > > scrambled data. (Attached reference file) > > > What I need is I want to extract out only the employee no which is only > > numerical value and nine digit number. I couldn’t use formulas like (LEFT, > > RIGHT or MID) as the count of numbers is not unique. > > > I have 200 such data’s to extract. Kindly help me. > > > Regards, > > > Selva Jayapal > > > -- > > > ------ > > Some important links for excel users: > > 1. Excel and VBA Tutorials(Video and Text), Free add-ins downloads at > >http://www.excelitems.com > > 2. Excel tutorials athttp://www.excel-macros.blogspot.com > > 3. Learn VBA Macros athttp://www.vbamacros.blogspot.com > > 4. Excel Tips and Tricks athttp://exceldailytip.blogspot.com > > > To post to this group, send email to excel-macros@googlegroups.com > > If you find any spam message in the group, please send an email to: > > Ayush Jain @ jainayus...@gmail.com or > > Ashish Jain @ 26may.1...@gmail.com > > <><><><><><><><><><><><><><><><><><><><><><> > > HELP US GROW !! > > > We reach over 6,500 subscribers worldwide and receive many nice notes about > > the learning and support from the group. Our goal is to have 10,000 > > subscribers by the end of 2009. Let friends and co-workers know they can > > subscribe to group at > >http://groups.google.com/group/excel-macros/subscribe > > > -- > > > ------ > > Some important links for excel users: > > 1. Excel and VBA Tutorials(Video and Text), Free add-ins downloads at > >http://www.excelitems.com > > 2. Excel tutorials athttp://www.excel-macros.blogspot.com > > 3. Learn VBA Macros athttp://www.vbamacros.blogspot.com > > 4. Excel Tips and Tricks athttp://exceldailytip.blogspot.com > > > To post to this group, send email to excel-macros@googlegroups.com > > If you find any spam message in the group, please send an email to: > > Ayush Jain @ jainayus...@gmail.com or > > Ashish Jain @ 26may.1...@gmail.com > > <><><><><><><><><><><><><><><><><><><><><><> > > HELP US GROW !! > > > We reach over 6,500 subscribers worldwide and receive many nice notes about > > the learning and support from the group. Our goal is to have 10,000 > > subscribers by the end of 2009. Let friends and co-workers know they can > > subscribe to group at > >http://groups.google.com/group/excel-macros/subscribe > > -- > With Love, > Mahesh Bisht > > Emp._No..xls > 45KViewDownload- Hide quoted text - > > - Show quoted text - -- -- Some important links for excel users: 1. Excel and VBA Tutorials(Video and Text), Free add-ins downloads at http://www.excelitems.com 2. Excel tutorials at http://www.excel-macros.blogspot.com 3. Learn VBA Macros at http://www.vbamacros.blogspot.com 4. Excel Tips and Tricks at http://exceldailytip.blogspot.com To post to this group, send email to excel-macros@googlegroups.com If you find any spam message in the group, please send an email to: Ayush Jain @ jainayus...@gmail.com or Ashish Jain @ 26may.1...@gmail.com <><><><><><><><><><><><><><><><><><><><><><> HELP US GROW !! We reach over 6,500 subscribers worldwide and receive many nice notes about the learning and sup
$$Excel-Macros$$ Re: Please HELP :-(((((
Hi Amods, Please find the user defined funtions for extracting the numbers and text. Function ExtractNumber(rCell As Range, _ Optional Take_decimal As Boolean, Optional Take_negative As Boolean) As Double Dim iCount As Integer, i As Integer, iLoop As Integer Dim sText As String, strNeg As String, strDec As String Dim lNum As String Dim vVal, vVal2 sText = rCell If Take_decimal = True And Take_negative = True Then strNeg = "-" strDec = "." ElseIf Take_decimal = True And Take_negative = False Then strNeg = vbNullString strDec = "." ElseIf Take_decimal = False And Take_negative = True Then strNeg = "-" strDec = vbNullString End If iLoop = Len(sText) For iCount = iLoop To 1 Step -1 vVal = Mid(sText, iCount, 1) If IsNumeric(vVal) Or vVal = strNeg Or vVal = strDec Then i = i + 1 lNum = Mid(sText, iCount, 1) & lNum If IsNumeric(lNum) Then If CDbl(lNum) < 0 Then Exit For Else lNum = Replace(lNum, Left(lNum, 1), "", , 1) End If End If If i = 1 And lNum <> vbNullString Then lNum = CDbl(Mid (lNum, 1, 1)) Next iCount ExtractNumber = CDbl(lNum) End Function Function ExtractString(rCell As Range) As String Dim iCount As Integer, i As Integer, iLoop As Integer Dim sText As String, strNeg As String, strDec As String Dim lString As String Dim vVal, vVal2 sText = rCell iLoop = Len(sText) For iCount = iLoop To 1 Step -1 vVal = Mid(sText, iCount, 1) If IsNumeric(vVal) = False Then i = i + 1 lString = Mid(sText, iCount, 1) & lString If IsNumeric(lString) = False Then If Len(lString) < 0 Then Exit For Else lString = Replace(lString, Left(lString, 1), "", , 1) End If End If If i = 1 And lString <> vbNullString Then lString = CStr(Mid (lString, 1, 1)) Next iCount ExtractString = lString End Function Thanks Valli "Unless you try to do something beyond what you have already mastered, you will never grow." On Jan 7, 7:09 pm, Amods Bagwe wrote: > Please help me to get solution . > > Need to split the numbers & words using formula & not macros. > > dsasd2323 fssdf34235 sdsefges34 44rrr4 > (In ths Alphanumeric value, the numbers & words should be separated in > different columns) > > EG: 123 abc45 tr OUTPUT Should be 123 45(One cell) abc tr(Another cell) > > The INTERNET now has a personality. YOURS! See your Yahoo! > Homepage.http://in.yahoo.com/ -- -- Some important links for excel users: 1. Follow us in TWITTER for tips tricks and links : http://twitter.com/exceldailytip 2. Excel and VBA Tutorials(Video and Text), Free add-ins downloads at http://www.excelitems.com 3. Excel tutorials at http://www.excel-macros.blogspot.com 4. Learn VBA Macros at http://www.quickvba.blogspot.com 5. Excel Tips and Tricks at http://exceldailytip.blogspot.com To post to this group, send email to excel-macros@googlegroups.com If you find any spam message in the group, please send an email to: Ayush Jain @ jainayus...@gmail.com <><><><><><><><><><><><><><><><><><><><><><> HELP US GROW !! We reach over 6,500 subscribers worldwide and receive many nice notes about the learning and support from the group.Let friends and co-workers know they can subscribe to group at http://groups.google.com/group/excel-macros/subscribe
$$Excel-Macros$$ Re: If Conditions - Urgent Help Required
Hi Abhishek, I hope this will help you. =IF(A2="A+",IF(B2="Cartons",IF(C2>=1,"Yes","No"),IF(B2="Bales",IF (C2>=1.5,"Yes","No"),IF(B2="Pallets",IF(C2>=2,"Yes","No"),IF (B2="Others",IF(C2>=3,"Yes","No"),) This formula assumes that Column A, B and C contains Category, Type of Cargo and Time taken respectively. Also remove the hour/hours in time taken using find and replace. Cheers, Valli On Jan 22, 1:35 am, Abhishek Jain wrote: > * > URGENT* > > Hi friends, > > Please help me on this: > > Category Type of Cargo Time > taken > A+ Cartons 1 > hour > A+ Bales > 1.5 hours > A+ Pallets 2 > hours > A+ Others 3 > hours > > I want to check the time taken and show the result as "Yes" or "No" as > detailed hereunder - > > > If the category is *not equal to* "A+" *- formula should return > > FALSE*(this is the first condition to be checked) > > If category is "A+" and Type of Cargo is "Cartons" and Time taken is more > > than 1 hour - it should say "Yes"> If category is "A+" and Type > of Cargo is "Bales" and Time taken is more > > than 1.5 hour - it should say "Yes"> If category is "A+" and > Type of Cargo is "Pallets" and Time taken is more > > than 2 hours - it should say "Yes"> If category is "A+" and Type > of Cargo is "Others" and Time taken is more > > than 3 hours - it should say "Yes" > Else > It should say "No" > > Please help me writing an if statement (or whatever that works) for this. > > Thanks in advance, > > Best regards, > > AJ -- -- Some important links for excel users: 1. Follow us on TWITTER for tips tricks and links : http://twitter.com/exceldailytip 2. Excel and VBA Tutorials(Video and Text), Free add-ins downloads at http://www.excelitems.com 3. Excel tutorials at http://www.excel-macros.blogspot.com 4. Learn VBA Macros at http://www.quickvba.blogspot.com 5. Excel Tips and Tricks at http://exceldailytip.blogspot.com To post to this group, send email to excel-macros@googlegroups.com If you find any spam message in the group, please send an email to: Ayush Jain @ jainayus...@gmail.com <><><><><><><><><><><><><><><><><><><><><><> HELP US GROW !! We reach over 6,700 subscribers worldwide and receive many nice notes about the learning and support from the group.Let friends and co-workers know they can subscribe to group at http://groups.google.com/group/excel-macros/subscribe