• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Macro for adding formula and sorting and extracting

paradise

Member
Hi,

I have a data from A:Y5000 with heading.Now,here in Z column I want to to add a formula= left((trim(D2)) and copied down as long as A:Y range has data.

Secondly,sort Z column alphabetically and extract in new worksheet that contains'P'

Thanx all of u in advance.
 
Attach a sample workbook (not a picture or pasted copy). Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.
Remember to desensitize the data.
 
I have modified above range for minimising.Before & after has been mentioned.
I hope this would suffice info.
 

Attachments

  • Extraction.xlsm
    14 KB · Views: 6
Hi !​
Code:
Sub Demo1()
    Range("E2:E" & ActiveSheet.UsedRange.Rows.Count).Formula = "=LEFT((TRIM(B2)),1)"
End Sub
Do you like it ? So thanks to click on bottom right Like !
Have u seen my ultimate required results in worksheet-'After-Final Result'
That results I require thru VBA code.
 
Secondly,sort Z column alphabetically and extract in new worksheet that contains'P'

What does contains'P' mean? See no P to sort on? Your final result does not sort, but filters for West. Why do you need column E in your After Working Sheet if it is not used in the final output. Your request other than finding the last row is at best confusing. Please clarify what you are trying to do? Why do you need VBA to filter if this is a built in function of Excel?
 
What does contains'P' mean? See no P to sort on? Your final result does not sort, but filters for West. Why do you need column E in your After Working Sheet if it is not used in the final output. Your request other than finding the last row is at best confusing. Please clarify what you are trying to do? Why do you need VBA to filter if this is a built in function of Excel?
I have modified the post #1 due to confidential data.I have attached in Post#4 and accordingly criteria.In that file worksheet "After-Final Result" is my ultimate result which I want to extract from worksheet 'Before' which is my raw data & worksheet between these two is one kind of helper.Hence my ultimate goal is "After-Final Result" worksheet.

I hope this would ease.
 
Hi !​
Code:
Sub Demo1()
    Range("E2:E" & ActiveSheet.UsedRange.Rows.Count).Formula = "=LEFT((TRIM(B2)),1)"
End Sub
Do you like it ? So thanks to click on bottom right Like !
This formula is awesome but it should be as long as the data are there and not more than that in either side.No more no less
 
The easiest way to do this is to use Power Query/Get and Transpose. Here is the MCode

Code:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type datetime}, {"Region", type text}, {"Product", type text}, {"Quantity", Int64.Type}}),
    #"Filtered Rows" = Table.SelectRows(#"Changed Type", each ([Region] = "West"))    #"Filtered Rows"

Highlight your table. Click on Power Query and select Get Data from Range or Table. Click on the Filter and uncheck all but West. Go to Home and Close and Load.
 

Attachments

  • Extraction.xlsm
    23.1 KB · Views: 4
Back
Top