• 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.

Getting data based upon Column Names (VBA)

vijay.vizzu

Member
Dear Blog Users,


I need your help, in my work. As i have read and inspired below topic regarding excel as database. http://chandoo.org/wp/2012/04/02/using-excel-as-your-database/. But if i want to display the records as per heading i am putting in the view sheet, how to do that i don't know. In my raw data it has around 30 to 50 columns. But after selecting the drop downs, i want to show some required fields from the raw data.


How to do that, Please help me to resolve.


Vijay
 
Hi Vijay,


If I have understand your query..


then, you actually want


Code:
Select "RequiredColumn1","RequiredColumn3","RequiredColumn9" from TBL where...


where [code]"RequiredColumn1","RequiredColumn3","RequiredColumn9"
are your selected heading from 30 to 50 Columns..


if yes... then its should be asked in SQL Forum.. :)


By the way..

I have changed the SQLSTR as per below..

[pre]'------
'Modified by Debraj as required by Vijay
For i = 2 To Cells(12, Cells.Columns.Count).End(-4159).Column
cname = cname & "," & """" & Cells(12, i) & """"
Next i
cname = Mid(cname, 2)
strSQL = "SELECT " & cname & " FROM [data$] WHERE "
'-----[/code][/pre]
Check the attached..


https://dl.dropboxusercontent.com/u/78831150/Excel/Excel-As-Database-demo-v1%20%28Vijay%29.xlsm


Regards,

Deb
 
Back
Top