| Highlighting cells within a worksheet |
|
 |
Index ‹ Microsoft ISV Community Center Forums ‹ Visual Basic for Applications (VBA)
|
- Previous
- 1
- 2
- Visual Basic for Applications (VBA) Excel 2000, MSAA, FirefoxHi,
I am trying to write a macro to copy data from Mozilla Firefox on to an excel worksheet. I am using MSAA. I find the root UI of firefox and then try to get the child interfaces using AccessibleChildren. The children array has seven elements. All except one, the one I need, returns an IAccessible. The one I need is an empty object and the execution stops at the "case object" bit of the code (shown below).
Can you help, please
Thanks.
Private Sub writeAccessibles(ByVal objAccessible As IAccessible) Dim children() As Variant, tempChild As IAccessible Dim i%, noChildren As Long, noBegotten As Long Accessibledetails objAccessible If objAccessible Is Nothing Then Exit Sub noChildren = objAccessible.accChildCount If noChildren > 0 Then ReDim children(noChildren - 1) As Variant AccessibleChildren objAccessible, 0&, noChildren, children(0), noBegotten For i = 0 To noBegotten - 1 Select Case TypeName(children(i)) Case "IAccessible" Set tempChild = children(i) Case "Object" Stop ' stops here when i = 3 ********* this is the problem Set tempChild = children(i) Case "Long" Stop Set tempChild = objAccessible.accChild(children(i)) Case Else Stop End Select Accessibledetails tempChild Next i
End If End Sub
- 3
- Visual Basic for Applications (VBA) Erratic Performance using Workbooks.Open
Using Excel 2003, I'm writing what should be a quick application using VBA to open a series of Excel files and perform nearly 800,000 calculations (sad, but true).
Typically, I use the Workbooks.Open method, either preceeded by Application.GetOpenFilename so the user can select the file to open or without where the filename is generated programatically.
I'm running into Error 1004 (application generated, no details) with this simple statement:
Workbooks.Open Filename:=sStats, Origin:=xlWindows, AddToMru:=False
If I paste the contents of sStats into the Excel file open dialog, the workbook opens. All similarly coded statements in this application (and every other time I've used it on other projects) work. I had the same problem earlier when I tried breaking one of the file handlers out in it's own sub, but that must have been scope -related as it worked once I put the code directly in the calling routine.
I've also tried declaring a workbook object and using the alternative form of the open method:
Dim ws as workbook
set ws = Workbooks.Open Filename:=sStats
Same result if I omit the named argument.
Any ideas As far as I can tell, the syntax here is right on and it works repeatedly, then fails at the same location without any apparent reason.
I've pasted the entire code module (so far) below. The offending line is highlighted in yellow several pages down.
Thx,
Larry
'--------------------------------------------------------------------------- 'MACROS FOR PROCESSING NIELSEN GALAXY FILES AND ESTIMATING STANDARD ERRORS '1/6/2007 by Larry Goldstein '--------------------------------------------------------------------------- Option Explicit
Public sSECalculator 'Nielsen NPM Standard Error Calculator Public sStats As String 'Sample statistics filename & path Public objSampleStats As Workbook 'Sample stats workbook object
Public Sub GetSECalculator()
Dim FileToOpen As Variant Workbooks("SE Generator.xls").Activate 'Select Galaxy Explorer File(s) FileToOpen = Application.GetOpenFilename("Standard Error Calculator (*.XLS),*.XLS", 1, "Open Nielsen Standard Error Calculator", MultiSelect:=False) On Error Resume Next If FileToOpen = False Then If Err.Number = 0 Then Exit Sub 'user clicked cancel End If End If On Error GoTo 0 sSECalculator = FileToOpen Set FileToOpen = Nothing End Sub
Public Sub GetNielsenFiles() Dim FileToOpen As Variant Dim lNdx As Long Dim lX As Long Workbooks("SE Generator.xls").Activate 'Select Galaxy Explorer File(s) FileToOpen = Application.GetOpenFilename("Microsoft Excel File (*.XLS),*.XLS", 1, "Open Galaxy Explorer Report", MultiSelect:=True) On Error Resume Next If FileToOpen = False Then If Err.Number = 0 Then Exit Sub 'user clicked cancel End If End If On Error GoTo 0
Range(Cells(10, 1), Cells(500, 1)).Clear
lNdx = 10 For lX = LBound(FileToOpen) To UBound(FileToOpen) Cells(lNdx, 1) = FileToOpen(lX) lNdx = lNdx + 1 Next Set FileToOpen = Nothing End Sub
Public Sub ImportSampleStats()
Dim dbSampleDB As Database Dim rstRecSet As Recordset
Workbooks("SE Generator.xls").Activate 'Open Access Database FileToOpen = Application.GetOpenFilename("Microsoft Access Database (*.MDB),*.MDB", 1, "Open Sample Statistics Database", MultiSelect:=False) On Error Resume Next If FileToOpen = False Then If Err.Number = 0 Then Exit Sub 'user clicked cancel End If End If On Error GoTo 0 Set dbSampleDB = DBEngine.OpenDatabase(FileToOpen) Set FileToOpen = Nothing 'Select Sample Statistics File(s) FileToOpen = Application.GetOpenFilename("Microsoft Excel File (*.XLS),*.XLS", 1, "Open Nielsen Sample Statistics", MultiSelect:=True) On Error Resume Next If FileToOpen = False Then If Err.Number = 0 Then Exit Sub 'user clicked cancel End If End If On Error GoTo 0
lNdx = 10 For Each File In FileToOpen Next Set FileToOpen = Nothing Set File = Nothing
End Sub
Public Sub SEGenerator() Dim c As Object Dim dtDate As Date 'report date Dim dtTest As Date 'test date to assess which broadcast month a given date falls in Dim lNdx As Long 'row index for Galaxy Reports Dim lRow As Long 'row counter Dim lWeekDay As Long 'day of week (Monday start) Dim objSampleStats As Object 'sample statistics worksheet object Dim objWorksheet As Object 'worksheet object Dim sFile As String 'filename and path Dim sParentPath As String 'path for the audience workbook Dim sPeriod As String 'period reported (daily, week, month) Dim sWorkbook As String 'Current Nielsen Galaxy workbook being processed Dim wbStatistics As Workbook Static stLastStats As String 'Last sample Stats file Workbooks.Open Filename:=sSECalculator, ReadOnly:=True Workbooks("SE Generator.xls").Activate Cells(7, 1) = sSECalculator lNdx = 10 Do Workbooks("SE Generator.xls").Activate sFile = Cells(lNdx, 1) 'Open selected Galaxy Report Workbooks.Open Filename:=sFile, Origin:=xlWindows, AddToMru:=False 'Save to new file with .SE.XLS extension (so original is unchanged sFile = Left(sFile, Len(sFile) - 3) & "SE.xls" ActiveWorkbook.SaveAs Filename:=sFile, _ FileFormat:=xlNormal, Password:="", WriteResPassword:="", _ ReadOnlyRecommended:=False, CreateBackup:=False 'Get renamed workbook name (w/out path) to retain as required to activate it later sWorkbook = ActiveWorkbook.Name 'To speed up this process we will not let the user view the changes as they are made. '# Application.ScreenUpdating = False '------------------------------------------------------------------------------------------------ 'Loop through all the worksheets '------------------------------------------------------------------------------------------------ For Each objWorksheet In Worksheets '-------------------------------------------------------------------------------------------- 'Check to see if this worksheet is a compressable report '-------------------------------------------------------------------------------------------- If Mid(UCase(objWorksheet.Name), 1, 10) = "TRACKING #" Then '---------------------------------------------------------------------------------------- 'Go into this worksheet and process it '---------------------------------------------------------------------------------------- objWorksheet.Activate '---------------------------------------------------------------------------------------- 'Get Sample Statistics '---------------------------------------------------------------------------------------- 'Identify/Open Nielsen Sample Statistics File sPeriod = UCase(Cells(2, 1)) If Left$(Trim$(sPeriod), 3) = "DAY" Or Left$(Trim$(sPeriod), 4) = "WEEK" Then sStats = "Natl_wk_" 'Parse out Month/Day/Year, find Monday of the week dtDate = CDate(Right(sPeriod, 10)) lWeekDay = Weekday(dtDate, vbMonday) dtDate = dtDate - (lWeekDay - 1) sStats = sStats & Format$(Month(dtDate), "00") & Format$(Day(dtDate), "00") & Right(CStr(Year(dtDate)), 2) & ".xls" Else sStats = "Natl__mo" 'Parse out Month/Day/Year dtDate = CDate(Right(sPeriod, 10)) 'If Sunday of week falls in the stated month, 'the broadcast month is the stated month; otherwise 'the broadcast month is the following month lWeekDay = Weekday(dtDate, vbMonday) dtDate = dtDate + 7 - lWeekDay sStats = sStats & Format$(Month(dtDate), "00") & Right(CStr(Year(dtDate)), 2) & ".xls" End If 'Open Sample Statistics File If sStats <> stLastStats Then If Len(stLastStats) > 0 Then Workbooks(stLastStats).Close End If sParentPath = objWorksheet.Parent.Path For lNdx = Len(sParentPath) To 1 Step -1 If InStr(lNdx, sParentPath, "\") <> 0 Then sParentPath = Left(sParentPath, lNdx) Exit For End If Next 'Save as static variable to avoid repeatedly opening the same file stLastStats = sStats sStats = sParentPath & sStats
This is where the application fails with no apparent cause. The file I am attempting to open does exist (Dir function returns the filename and Excel can open it manually). Workbooks.Open Filename:=sStats, Origin:=xlWindows, AddToMru:=False 'Calculate % coverages for each cable network and add to Sample Statistics 'First check to assure this hasn't been done already (for updates/reprocessing, etc.) Workbooks(stLastStats).Activate Cells(4, 12) = "% 21+ U.S. Coverage" With Worksheets(1).Range("D1:D500") Set c = .Find("PERSONS 21+", LookIn:=xlValues) If Not c Is Nothing Then lRow = c.Row + 1 Do If IsNumeric(Cells(lRow, 5)) Then Cells(lRow, 12) = Cells(lRow, 5) / Cells(c.Row, 5) * 100 Else Cells(lRow, 12) = 0 End If lRow = lRow + 1 Loop While Cells(lRow, 4) = "PERSONS 21+" End If End With End If SECalc objWorksheet, stLastStats End If Next objWorksheet '# Application.ScreenUpdating = True Workbooks("SE Generator.xls").Activate lNdx = lNdx + 1 Loop Until Len(Cells(lNdx, 1)) = 0 End Sub
'SECalc Sub 'Process Standard Errors for all rows in the current worksheet Private Sub SECalc(objWorksheet As Worksheet, sStats As String)
On Error GoTo SECalcErr Exit Sub SECalcErr: MsgBox "Error " & Err.Description & " in SECalc" End Sub
'--------------------------------------------------------------------------- 'END MACRO COLLECTION FOR PROCESSING NIELSEN GALAXY AND STANDARD ERRORS '---------------------------------------------------------------------------
- 4
- Visual Basic for Applications (VBA) troubleshooting saving versions with macro in WordHi, a while back I asked how I could save a version of the document automatically every 15mins. I managed to write a macro to do this and it worked for most documents. However, for some documents the versions were saved but when I open any of them they appear identical to the current document. Also, in a couple of cases I had this problem initially and then after a few attempts it sorted itself out - not sure how...
The macro was written for the specific document and the code looked like this
Sub AutoOpen() Application.ActiveDocument.Versions.Save Comment:="" Application.OnTime When:=Now + TimeValue("00:15:00"), _ Name:="AutoOpen" End Sub
I can't be sure what version of Word the document was written in (I saved the original doc with the macro in 2003 and then passed it onto to others). Also, in some cases there were about 40-50 versions saved, although I have the same problem on a doc with 15 versions.
Can anyone suggest what might have gone wrong - or how I might be able to retrieve the version info
Thanks for any suggestions!
- 5
- Visual Basic for Applications (VBA) Using Paste in the File Save as window
Hi all I only know a little about VB but have made a form on word that copys a word from the document saves itself to a folder prints a copy and then exits word. it all works fine except i cannot get it to paste the word from the document in the fileName when it saves. The script is below with red showing the problem. Any help on this would be much apreciated
Mark
Sub Process() ' ' Process jobsheet macro ' Macro recorded 09/01/2007 by Mark Smith ' ActiveDocument.Shapes("Text Box 6").Select Selection.WholeStory Selection.Copy ChangeFileOpenDirectory _ "E:\Global Internet Learning Ltd Files\Duplication Centre\Client Job Sheets\" ActiveDocument.SaveAs FileName:= , FileFormat:= _ wdFormatDocument, LockComments:=False, Password:="", AddToRecentFiles:= _ True, WritePassword:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:= _ False, SaveNativePictureFormat:=False, SaveFormsData:=False, _ SaveAsAOCELetter:=False Application.PrintOut FileName:="", Range:=wdPrintAllDocument, Item:= _ wdPrintDocumentContent, Copies:=1, Pages:="", PageType:=wdPrintAllPages, _ ManualDuplexPrint:=False, Collate:=True, Background:=True, PrintToFile:= _ False, PrintZoomColumn:=0, PrintZoomRow:=0, PrintZoomPaperWidth:=0, _ PrintZoomPaperHeight:=0 ActiveWindow.Close Application.Quit End Sub
- 6
- Visual Basic for Applications (VBA) ComboBox: VBCode to select first item in the list.
Hi
I have the following VB code, when someone selects the worksheet name from the combo box in the summary page it takes them to the worksheet. However, the problem is that if they select, for example, worksheet "B" it takes them to the worksheet fine but when they are back in the summary worksheet the "B" is still selected in the combo box and you can not select "B" anymore. You have to select other worksheet name before you can select "B" again. Is there any way to instruct the combo box to always select the first item in the list Thanks in advance.
Private Sub AFISGBox_Change() Dim strSheet As String If AFISGBox.ListIndex > -1 Then strSheet = AFISGBox Sheets(strSheet).Select End If End Sub
- 7
- Visual Basic for Applications (VBA) Multiple series addition problem
I am not sure whether thisis the right place for this question. This is a problem which i am facing when coding in VB.net
The problem is,
I want to draw a line graph (3 series) in excel from the data present in designated positions in Excel. I worte a code which is as below
charts = XLSheet.ChartObjects() ' Adding a chart chartObj = charts.Add(450, 200, 350, 200)
Dim lIntI As Integer = 1 Dim xlsAxisCategory, xlsAxisValue As Excel.Axes With chartObj .Name = "Cumulative Defects1" .Chart.ChartType = Excel.XlChartType.xlLineMarkersStacked .Chart.ProtectGoalSeek = False '.Chart.SetSourceData(chartRange) seriesCollection = .Chart.SeriesCollection() For lIntI = 1 To paramColDaysStart.Count seriesCollection.NewSeries() seriesCollection.Item(lIntI).Values = _ XLBook.Worksheets(paramSheetName).range(XLSheet.Cells(paramRowDaysStart, paramColDaysStart.Item(lIntI - 1)), XLSheet.Cells(paramRowDaysEnd, paramColDaysEnd.Item(lIntI - 1))) .Chart.SeriesCollection.Item(lIntI).Name = paramSeriesNames.Item(lIntI - 1) Next End With
With chartObj 'Creating(name) .Name = "Cumulative Defects1" .Chart.ChartType = Excel.XlChartType.xlLineMarkersStacked .Chart.SetSourceData(chartRange) .Chart.HasTitle = True .Chart.ChartTitle.Caption = "Cumulative Defects" ' Setting title
'getting the series collection seriesCollection = chartObj.Chart.SeriesCollection()
'Naming the series seriesCollection.Item(1).Name = "No. of defects" seriesCollection.Item(1).MarkerBackgroundColorIndex = Excel.XlColorIndex.xlColorIndexAutomatic seriesCollection.Item(1).MarkerForegroundColorIndex = Excel.XlColorIndex.xlColorIndexAutomatic ' Counting series = seriesCollection.Item(seriesCollection.Count)
'Getting the axis of the charts 'X(axis) xlsAxisCategory = .Chart.Axes(, Excel.XlAxisGroup.xlPrimary) xlsAxisCategory.Item(Excel.XlAxisType.xlCategory).HasTitle = True xlsAxisCategory.Item(Excel.XlAxisType.xlCategory).AxisTitle.Characters.Text = "No. of days" xlsAxisCategory.Item(Excel.XlAxisType.xlCategory).HasMajorGridlines = False xlsAxisCategory.Item(Excel.XlAxisType.xlCategory).HasMinorGridlines = False xlsAxisCategory.Item(Excel.XlAxisType.xlCategory).AxisTitle.Interior.PatternColorIndex = 2 ' Y Axis xlsAxisValue = .Chart.Axes(, Excel.XlAxisGroup.xlPrimary) xlsAxisValue.Item(Excel.XlAxisType.xlValue).HasTitle = True xlsAxisValue.Item(Excel.XlAxisType.xlValue).AxisTitle.Characters.Text = "No. of Defects" xlsAxisValue.Item(Excel.XlAxisType.xlValue).HasMajorGridlines = True xlsAxisValue.Item(Excel.XlAxisType.xlValue).HasMinorGridlines = False xlsAxisValue.Item(Excel.XlAxisType.xlValue).AxisTitle.Interior.PatternColorIndex = 2 .Chart.SeriesCollection(1).border.Weight = Excel.XlBorderWeight.xlThin .Chart.HasTitle = True .Chart.ChartTitle.Caption = "Cumulative Defects" 'Setting(title)
'Positioning the legend .Chart.ChartArea.Font.Background = Excel.XlBackground.xlBackgroundTransparent .Chart.Legend.Position = Excel.XlLegendPosition.xlLegendPositionRight
'Coloring the area .Chart.PlotArea.Interior.ColorIndex = 19 .Chart.ChartArea.Interior.ColorIndex = 2 .Chart.ChartArea.Interior.PatternColorIndex = 2 .Chart.Legend.Interior.PatternColorIndex = 2 chartObj.Interior.PatternColorIndex = 2 .Chart.Location(Excel.XlChartLocation.xlLocationAsObject, paramSheetName) End With XLBook.Save() generalfunctions.ReleaseExcelObjects(XLApp, XLBook)
In the above code paramSeriesNames has the names for the series which is a hash table
paramRowDaysStart is a integer value which denotes the start row value, paramColDaysStart is a hash table which has the starting column for the series
paramRowDaysEnd is a integer value which denotes the end row value, paramColDaysEnd is a hash table which has the ending column for the series
In this noth paramColDaysEnd and paramColDaysstart will have same values because i am using only one column series
The problem is, when i am adding a new series in the loop (say 3 series), the first series is coming properly, the second series is displaying as the sum of first series column values and the second series column (13,2 - 24,2) + (13,4 - 24,4)
Third series is the sum of all ie (13,2 - 24,2) + (13,4 - 24,4) + (13,6 - 24,6)
I am not sure y this is happening. If i print only one series then everything is proper. how to correct this problem
I want a result like below
Series1 = (13,2 - 24,2) Series2 = (13,4 - 24,4) Series3 = (13,6 - 24,6)
But actual result is
Series1 = (13,2 - 24,2) Series2 = (13,2 - 24,2) + (13,4 - 24,4) Series3 = (13,2 - 24,2) + (13,4 - 24,4) + (13,6 - 24,6)
Please help me friends
Albert
- 8
- Visual Basic for Applications (VBA) Simple thing: how to append to a jagged array?Hi,
I'm a newbie in coding, sorry for an elementary question.
' I have arrays e.g. a = Array(1, 11, 111) b = Array(2, 22, 222) 'then I create a jagged array: bigarray = Array(a,b) 'this works ok, I can address it by bigarray()() 'But how can I declare this bigarray in the first place so I can then append next small array to it. c=Array(3,33,333) 'and here I'd like to append this c to existing bigarray How do I do it
Many thanks in advance
- 9
- ISV Open Discussions Contact in Canada
Hi,
I'm from Brazil and this year I want to find a job in Canada. Preferably something with .NET. Is anybody here from Canada I want to talk with somebody to know more about life in Canada, career and this stuffs...
My messenger address is:d_foliveira@hotmail.com .
Thanks a lot. I really appreaciate some help.
[]'s
- 10
- Visual Basic for Applications (VBA) Summing up hours on form based on parameter query
Hi there - im finalising my new activity system but i have one issue.
on an activity form i have certain fields for information purposes that are non editable - they are 'hours worked with client' , 'hours worked this month' and 'hours worked for the day'. The first 2 fields are populated automatically by opening recordsets on form load or companyname exit and summing up the hours based on the relevant query where the criteria ensures that the query is already populated.
However for the 'hours worked for the day' field the query is a parameter query (qrytodayhours) where activitydate = Forms![frmactivity]![activitydate] and i was then hoping to enter the following code to sum up the hours using a recordset on the on exit of the activitydate field:
Dim rstemp As Recordset Set rsdbase = CurrentDb
Set rstemp = rsdbase.OpenRecordset("SELECT SUM(activityhours)AS [sumtodayhours] FROM [qrytodayhours] WHERE [leadofficer]='" & loginname & "'") With rstemp .MoveFirst 'Me.sumtodayhours = Format(Nz(!sumtodayhours, 0), "#,##0.00") ' or whatever format you prefer .close End With
If i dont enter this code in and just enter a date into the form and then open the query then i can see that the parameter query works because i get the correct information in the query. However i cant get it to sum the hours up and enter it into the field 'sumtodayhours' as i can with the other fields mentioned at the start.
The error message i get when i exit the 'activitydate' field is 'Too few parameters. Expected 1'.
Do i need to use a querydef to open the recordset or is there something i am missing
Any ideas would be gratefully appreciated.
Many thanks,
Rhys.
- 11
- 12
- 13
- Visual Basic for Applications (VBA) Link Table
i have a link table in access which is linked to SQL Server, by opening the linked table itself, i could see the records etc, but if i try to access the link table through vb coding, it is saying that i dont have permission to SQLServer. How to overcome this issue.
Many Thanks
Syed
- 14
- Visual Basic for Applications (VBA) ActiveX Slider Control 6.0 (SP4) Problem
Hi everyone,
The 'On Updated' event does not fire after having modified the slider position.
This is an MS Access VBA development project.
Can anyone tell me how to get this event to fire Or is there another way that I can recover the value of the slider position after the user has moved it
Any help or other pointers will be greatly appreciated !
Many thanks,
Lars
- 15
- Visual Basic for Applications (VBA) sending emails from MS Word with variable subject line
Hi,
I've searched these forums but have not been able to find exactly what I need.
I know how to send emails with VBA in Word, but the only problem I have is that as far as i'm aware the subject line is always fixed in the code ( .Subject = "New subject" )
What i'm trying to do, is send reports i have reviewed to an email address by clicking a button in the toolbar. The email address is always the same but the subject line shows the customer's name and his account number (so that's different all the time)
Is there any way I can get the VBA code to copy the first line of the report (which has the customer's account number and name) and use that in the subject line
Many thanks for your help in advance.
|
| Author |
Message |
pfunkmasterflex

|
Posted: Visual Basic for Applications (VBA), Highlighting cells within a worksheet |
Top |
Several of us in our office have a fantasy golf league and we administrate it off-line using an excel spreadsheet (we haven't found a free website that lets us tailor the rules to the way we like it.)
Anyway, it is a salary cap format, meaning that only one golfer can be on one team at a time. To keep track of this, one of our worksheets has a list of all the golfers. That same worksheet also has every team's roster. For all golfers that are on someone's roster, I manually highlight that same name in the master list of golfers so it is easy to see who is taken and who is available.
What I'd like to be able to do is have it automatically highlight that golfer's name in the master list when it appears in the individual team roster's page (and conversely un-highlight the name when the player is dropped). But I don't know what the VBA code should be.
Below is an example of how it looks:

you can see the master list on the left and the team rosters on the right. Any help would be greatly appreciated. Thanks!
Microsoft ISV Community Center Forums3
|
| |
|
| |
 |
Andy Pope

|
Posted: Visual Basic for Applications (VBA), Highlighting cells within a worksheet |
Top |
Hi,
It's possible with formula.
Select the range A2:D34 or where ever the list of players ends. The apply conditional formatting. menu Format > Conditional Formatting...
Change the Cell Value option to Formula and use this formula.
=SUMPRODUCT(--($F$3:$R$23=$B2))>1
Set the pattern to be Red
Add another condition with the formula
=SUMPRODUCT(--($F$3:$R$23=$B2))=1
Set the pattern to Green.
The default pattern for a cell should be automatic. Now when a players name appears once in the range F3:R23 they should be highllighted in green. More than once in Red.
|
| |
|
| |
 |
pfunkmasterflex

|
Posted: Visual Basic for Applications (VBA), Highlighting cells within a worksheet |
Top |
Thanks for the help! It seems to work most of the time, but there is the sporadic ones that don't highlight that should be highlighted and vice versa. I'm leaving work now but I'll have time to look into it more closely next week.
Thanks again!
|
| |
|
| |
 |
Andy Pope

|
Posted: Visual Basic for Applications (VBA), Highlighting cells within a worksheet |
Top |
Check for missing/extra spaces in or at the end of names.
Are you using data validation lists for the team selection or are you re-typing or maybe cut/paste
|
| |
|
| |
 |
| |
 |
Index ‹ Microsoft ISV Community Center Forums ‹ Visual Basic for Applications (VBA) |
- Next
- 1
- Visual Basic for Applications (VBA) Outputting to a Listbox
Hi;
I have a list of data, and need for values outside a lower and upper bound to be flagged up to the user. I was thinking of outputting to a listbox, but cant get the code to work. I was wondering if anyone had any ideas for possible code, or a better way of outputting to the user.
Ryan
- 2
- 3
- 4
- 5
- ISV Open Discussions pogo gamesI use att yahoo and when i play pogo games i do not hav ea chat box, anyone know what i can do to correct the problem. i get the chat box when i use ie, but that is when i get the application error message when i log off.
- 6
- Visual Basic for Applications (VBA) Delete Unwanted rows based on value in cell
Hi all,
I have to loop through a range of rows with an excel sheet and delete unwanted data. To identify the rows to be deleted I have to do the following:
Firstly I must start at A1 and check if it contains the value "Product", if not i go to the next row but if it does i must then delete this row and go to the next.
I must then check that the next cell contains the value "Total", if not i go to the next row but if it does i must then delete this row and go to the next.
I then need to delete each of the next rows until i find the next cell that contains the value "Product", delete this cell and then go through each of the next rows until i find the next cell that contains the value "Total".
This process is repeated 3 times.
so it sort of looks like: -delete rows -find product value -don't delete rows -find total value -repeat from step 1 again
its a difficult task but help greatly appreciated
- 7
- Visual Basic for Applications (VBA) Projects, objects & modules
I
started learning VBA in MS Word yesterday. I have some programming
experience in C++ and Java. I am trying to understand how the
environment is structured and what Projects, Objects and Modules
represent.
For example I recorded a few macros using the macro recorder and
then opened the VB Editor to see what was created. I notice that under
"Project" are 3
folders. One is named "Microsoft Word Objects". Within this folder is
what looks like a file named "This Document". What does "Project" represent What does "This Document"
represent What is the difference between "This Document" and the
"Project"
Also under "Project" is a folder named "Modules". Within this
folder is what looks like a file named "New Macros". This "file" seems
to hold the code that represents the macros I recorded. Right clicking
on the "Modules" folder allows me to insert another module into which I
can add code for a Sub/s (short for subroutine/s I assume) via the VB
Editor to do whatever.
Why would you put code for different Subs into different modules
The simple tutorials I have been studying seem to put all Subs into the
one module. Why is the code for the recorded macros put into a separate
module
I am trying to work out exactly what Projects, Objects, and Modules
are and how they interact. It seems like some sort of hierarchy. This
environment is very new and quite confusing to me at the moment. Any
help or references appreciated.
- 8
- Visual Basic for Applications (VBA) Creating and Editing Microsoft Access Reports using Visual Basic
Hi,
I am trying to create a report based on the selection from a combo box in a form.
i have some data, of which one of the fields is callled "projects". the combo box selects selects a project, and i would like to be able to open a report showing the data that belongs to the specific project on the click of a button.
i have written the code below, but the report is only ever blank. i can create a query based on the same sql statement, and it works fine. can someone help
Dim thisDB As Database, strSql, projID As String, rpt As Report Set thisDB = CurrentDb
projID = existingProjSelector.Value strSql = "SELECT * FROM MyTable WHERE ([PROJECT ID]='" & projID & "');"
' the following query code is commented out but works fine
' thisDB.CreateQueryDef "reportQry", strSql
'DoCmd.OpenQuery "reportQry" ' thisDB.QueryDefs.Delete "reportQry"
' why doesnt this work DoCmd.OpenReport "Report1", acViewPreview, , strSql
i would also like to know now to change the way the data is grouped on the report etc using vb
cheers, ben
bennymacca6@hotmail.com.dontspamme
- 9
- Visual Basic for Applications (VBA) Cell Equal To EXACT Value
Hi all,
prob a very simple question for you guys. How do you check if a cell equals an exact value of "Product"
I am currently using:
Cells(i, 1).Text = "PRODUCT"
though this is also picking up any cell which contains the word Product, such as cells which contain the word Production.
So how do you check for an exact value
- 10
- Visual Basic for Applications (VBA) Using VBA macro to locate next free column on worksheetI need a macro that locates the next free
column (i.e. has no data in cells) and then places the cursor in a cell on a
designated row. Would like search to start from column B and to place the cursor
on row 4 on the free column.
<>
My VBA code thus far:
Function NewColNumber(Range1 As Range) As
Integer
Dim j As Integer
For j = 1 To Range1.Columns.Count
If Range1.Columns(j) = "" Then
NewColNumber = Range1.Columns(j).Column
Exit Function
End If
Next
End Function
Sub SaveCOLComments()
On Error GoTo Err_Part
Dim Range1 As Range
Dim intNewColNumber As Integer
'
Go to Sheet1 and COPY field range content the go to Sheet2
Sheets("Sheet1").Select
Range("F2:F6").Select
Selection.Copy
Sheets("Sheet2").Select
'
Obtain the next free column using range set in range1
Set Range1 = Worksheets("Sheet2").Range("c4:z4")
'
Obtain the next available column number and place cursor in row 4
intNewColNumber = NewColNumber(Range1)
Worksheets("Sheet2").Cells(intNewColNumber, 3).Select
'
PASTE the field range content obtained from Sheet1 into row 4 of column
ActiveSheet.Paste
MsgBox ("The field content has been copied."), vbOKOnly,
" Test Macro", a, a
Exit_Point:
Exit Sub
Err_Part:
MsgBox Error$()
Resume Exit_Point
End Sub
- 11
- Visual Basic for Applications (VBA) Create new "category" of functions
Dear all,
I have created some functions in my macros. If I select a cell and try to "insert funtion" in this cell, my created functions appear inside the "user defined functions" category.
Is it possible to create different categories of functions (as the already existing "text", "financial", "date & time",...) in order to divide all my functions between these new categories and have a clear structure, instead of having all of them mixed
Thanks!
- 12
- 13
- 14
- 15
- Visual Basic for Applications (VBA) Run Time Error 9 when Calling a UserformHi folks,
I am getting a run time error # 9 when I run a macro that calls a Userform or when I try to run code in a Userform module. The code performs beautifully on my computer, but it did not work on a coworker's computer. It ended up working on 3 out of the 5 computers I have tried it on.
I have tried changing security settings to low, and a bunch of other stuff, but I cannot get the code to run on the computers that get the run time error on them when I try running the code on them.
I get the run time error when I try to load or show any userform in the workbook and I get it if I try to run code that is in the userform module. However, if I paste the code into a regular module and run it, the code runs fine.
Does anyone know what could be causing this I don't my code is causing the problem since it runs on some machines, I am guessing there is a setting that is preventing Excel from calling Userforms. Any ideas
Thanks,
Joe
|
|
|