Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default How to know cell's address from Excel Query

I try to get cell's address through Excel Query to delete the range
manually.
For example

SELECT Emp_Name FROM Employee
WHERE Emp_ID='1'

I want to know where the data located in Excel, so i can delete the
range that contain the data. Is it possible?

Thanks,

Resant

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 789
Default How to know cell's address from Excel Query

Hi
You need to filter the Employee with Emp_Name and Emp_ID = "1". Record
a macro while you do this manually and you should have the code. Also,
Google this group for "filtering a range using 2 criteria"
regards
Paul

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default How to know cell's address from Excel Query

Hi Paul,

I can't use filter, cause there's others data beside "Employee" Range.
So I must get the Cell Address where Emp_Name located.
For example, Emp_Code located in $C$4, i will use the Cell's Row with
the code :

Sub Delete()
Intersect(Range("Employee"), Range($4:$4)).Select
Selection.Delete Shift:=xlUp
End Sub

Please help me, any example will be appreciated

Thanks

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 789
Default How to know cell's address from Excel Query

Hi
Your delete sub will only delete the cells in Range("Employee"), so I
don't understand why you cannot combine this with Filter.

Suppose Employee Name is in column 1 and Emploee ID is in column 2

Public Sub RemoveEmployees(Emp_Name as String, Emp_ID as Integer)
'Remove any filter present on the Range
'Filter by Name and ID for your values Emp_Name and Emp_ID, delete
entries and show remaining
'Range("Employee") should not include a Heading. If it does, use
Range("Employee").offset(1,0)
With Range("Employee")
.Parent.AutoFilterMode = False 'Removes drop down arrows
.AutoFilter Field:=1, Criteria1:=Emp_Name 'column 1
.AutoFilter Field:=2, Criteria1:=Emp_ID 'column 2
.SpecialCells(xlCellTypeVisible).Delete Shift:=xlUp
.Parent.AutoFilterMode = False 'Removes drop down arrows
End With

End Sub

Calling RemoveEmployees("John", 1) will remove the rows in "Employees"
with name in column 1 of "John" and ID number in cloumn 2 of 1.

regards
Paul

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 789
Default How to know cell's address from Excel Query

oops
should be called as
RemoveEmployees "John", 1

no brackets
Paul



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default How to know cell's address from Excel Query

Great!
I've got your idea now...

But you can not delete the cells when AutoFilter is still active, this
will delete the entire row.
So, get the address, off the filter and delete the desire cells, right?
Thanks a lot!

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need to refer to a cell's address, not it's content... aduroche Excel Discussion (Misc queries) 3 October 18th 07 08:54 PM
Repeat: Active Cell's Address Milind Excel Programming 2 September 30th 05 01:47 AM
cell's address of the largest number novio Excel Discussion (Misc queries) 1 April 9th 05 10:16 PM
How can I change a text to a cell's address? Antônio Sobral Excel Discussion (Misc queries) 0 February 15th 05 04:55 PM
How do I programmatically know the current cell's address Keith[_5_] Excel Programming 3 September 9th 03 08:00 PM


All times are GMT +1. The time now is 02:54 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"