Home > Software engineering >  VB and EXCEL data problems
VB and EXCEL data problems

Time:10-05

How to satisfy the conditions in VB window for EXCEL, and read into the text box of VB, if there is no data will be appended to the EXCEL table,

CodePudding user response:

This stuff, you record a macro is not solved?
 Option Explicit 
The Function FindExcelStr (ByVal fStr As String) As String
' 'demonstration in A column to find the appropriate content, if not found then add
Dim Rng As Excel. Range, Rng2 As Excel. As Long Range, k
Set Rng=Sheet1. Columns (" a: "a)
The Set Rng2=Rng. Find (fStr)
If Rng2 Is Nothing Then
"' if you don't find the add
K=Sheet1. Range (" a "& amp; Sheet1. Cells. Rows. Count). The End (xlUp). The Row lines' final data
If k=1 Then If the Range (" a1 ")="" Then k=0
Sheet1. Cells (k + 1, 1)=fStr
FindExcelStr="new" 'said the newly added
The Else
FindExcelStr=Rng2. Address 'return Address
End the If
End the Function
Sub test ()
The Debug. Print FindExcelStr (" WWW ")
End Sub

CodePudding user response:

Matching: if it is a cell using the Set Rng2=Rng. Find (fStr, LookAt:=xlWhole)
  • Related