来来回回折腾半天;
Sub get_exporesure()
Dim Cnn As Object, Sql As String, S(1) As String
Dim seprate_line
Dim Context As String '声明一个String类型变量context,用于保存对话框将要显示的内容
Dim title As String '声明一个String变量title,同于保存窗口标题内容
Rem 将内容存入Conetext 变量
seprate_line = "------------------"
Context = "TO get exploresure!"
title = "get exploresure"
key_word = "25mm eyelashes"
Set Cnn = CreateObject("ADODB.Connection")
Cnn.Open "Provider=Microsoft.ACE.OLEDB.12.0;Extended Properties=Excel 12.0;Data Source=" & ThisWorkbook.FullName
S(0) = "[" & ActiveSheet.name & "$B1:B" & Range("B65536").End(xlUp).Row & "]a"
'S(1) = "[" & ActiveSheet.Name & "$J1:L" & Range("J65536").End(xlUp).Row & "]b"
Rem Sql = "SELECT b.商品价格,b.商品单位 FROM " & Join(S, " LEFT JOIN ") & " ON a.商品名称=b.商品名称"
'Range("C2").CopyFromRecordset Cnn.Execute(Sql)
Cnn.Close: Set Cnn = Nothing: Beep
'MsgBox Context, vbOKOnly, title
Dim st As Worksheet
Set st = Sheets("source_data_top_rank_eyelashes")
temp = st.Range("1:" & st.Rows.Count).Find(key_word).Address
col_num = Split(temp, "$")(1)
row_num = Split(temp, "$")(2)
Debug.Print "列号:" & col_num & " 行号:" & row_num
Debug.Print seprate_line
target_row = st.Range("1:" & st.Rows.Count).Find(key_word).Address
Debug.Print target_row
endrow = st.Range("A65536").End(xlUp).Row
endcol = st.Range("iv1").End(xlToLeft).Column
Debug.Print "endrow:" & endrow & " endcol:" & endcol
Debug.Print seprate_line
Set test_kw = st.Range("1:" & st.Rows.Count).Find("曝光")
Debug.Print seprate_line
Debug.Print test_kw.Address, test_kw.Row, test_kw.Column, test_kw.Value
End Sub
本文介绍了如何使用VBA在Excel中进行基础查找操作,并详细阐述了如何获取找到的单元格的行列号及其完整地址,帮助提升VBA编程效率。
3万+

被折叠的 条评论
为什么被折叠?



