|
||||||
| Visual Basic Programming Discussion forum for Visual Basic, an event driven programming language and associated development environment from Microsoft for its COM programming model. |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||
|
hi all,
I need to write a VBA code which will search data in 'Bold' from a list. It should be in dynamic array since the data will be updated constantly. I met many problem with this....attached is the data i need to work on...thanx a lot Code:
Sub DynamicArray()
Dim Device() As String ' declares a dynamic array variable
Dim iCount As Integer
Dim Max As Integer
Worksheets("Proto & Other Experiment").Activate
ActiveSheet.Range("B2").EntireColumn.Select
' Device = Selection.FindText(True, LookIn:=xlsPattern)
Max = Worksheets("Proto & Other Experiment").Device.Count ' finds the maximum array size
ReDim Device(1 To Max) ' declares the array variable with the necessary size
For iCount = 1 To Max
Device(iCount) = Worksheets("Proto & Other Experiment").Device(iCount)
Next iCount
Erase Device() ' deletes the varible contents, free some memory
End Sub
Last edited by Jordan; 01-24-2008 at 08:41 AM. |
| Sponsored Links |
|
|
|
|||||
|
Moved to correct forum. Added code tags.
Code:
With currentFind.Font
.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Red)
.Bold = True
End With
How to: Search for Text in Worksheet Ranges And is an example of how to set a bold font. Just reverse it with an if statement to find bold selections.
__________________
CodeCall Blog | CodeCall Wiki | Shareware Site | Linux Forum | Write a Blog The CodeCall Wiki is now fully integrated with vBulletin users! Check it out and add some new pages! |
|
|||
|
hey, thanx for the help...i hv write out the code as below...but keep having error in this line [For arr = 0 To Device(arrAddr).Size]
Ani cant figure out the error...pls help me on tt..thanx Code:
Sub DynamicArray()
Dim Device() As String ' declares a dynamic array variable
Dim iCount As Integer
Dim Max As Integer
Max = 0
Worksheets("Proto & Other Experiment").Activate
ActiveSheet.Range("B2").EntireColumn.Select
For row = 2 To 200
If Cells(row, 2).Font.Bold = True Then
Max = Max + 1
End If
Next row
ReDim Device(Max)
arrAddr = 0
For row = 2 To 200
If Cells(row, 2).Font.Bold = True Then
Device(arrAddr) = Cells(row, 2).Value
arrAddr = arrAddr + 1
End If
Next row
For arr = 0 To Device(arrAddr).Size 'Size of the array
ODBCConn (Device(arrAddr))
Next arr
End Sub
Last edited by TcM; 01-26-2008 at 04:57 AM. Reason: USE THE CODE TAGS!! |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
| WingedPanther | ........ | 2753.6 |
| Xav | ........ | 2704 |
| Brandon W | ........ | 1702.32 |
| John | ........ | 1207.73 |
| marwex89 | ........ | 1175.24 |
| morefood2001 | ........ | 966.05 |
| dcs | ........ | 655.75 |
| Steve.L | ........ | 475.59 |
| orjan | ........ | 418.58 |
| Aereshaa | ........ | 383.54 |
Goal: 100,000 Posts
Complete: 97%