Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
- Set a refererence to the MS VBA Extensibnility library: menu Tools References, add 'Microsoft Visual Basic for Application Extensilbility Library' - in the search code, you can use the Find method or you can loop through the lines, eg: Dim v As VBProject Dim c As CodeModule Dim subName As String Dim modName As String Dim startline As Long, endline As Long modName = "Module1" subName = "test" Set v = ThisWorkbook.VBProject Set c = v.VBComponents(modName).CodeModule startline = c.ProcStartLine(subName, vbext_pk_Proc) endline = startline + c.ProcCountLines(subName, vbext_pk_Proc) - 1 'Is the string within the sub code? MsgBox c.Find("Hello", startline, -1, endline, -1, False, False, False) 'Where is it? 'loop throught the Lines of c: c.Lines(i,1) Check the ObjectBrowser/OnlineHelp for more details and other methods or properties of the CodeModule object. Also, 'Find' can search for complex patterns (Regular Expressions). Regards, Sebastien "Ajit" wrote: How can i find the number of line for a particular piece of code in a procedure. -- Ajit |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Macro to change position of chart labels on line chart | Charts and Charting in Excel | |||
Macro code to put series name next to individual line in line grap | Charts and Charting in Excel | |||
Excel 2003 Line Chart - Switch Axis Position | Charts and Charting in Excel | |||
auto position of data labels in a line chart | Charts and Charting in Excel | |||
Line position in code | Excel Programming |