Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




Highlight Empty Cell In Excel


What is the VB code I should use to browse through a database in a spreadsheet, and then hilight any cells that are blank?

Thank you!




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Excel Help - First Empty Cell
Hi,

I would like to select the first empty cell in a column and then add text to it from a textbox on the userform. What I use is

Code:
Sheet2.Range("B1").End(xlDown).Offset(1, 0).Value = TextBox1.Text
and that works fine,

but then when I try

Code:
Sheet2.Range("J2").End(xlDown).Offset(1, 0).Value = Sheet1.Cells(1, 4).Value
I get the error

'Run-time error '1004':
Application-defined or object-defined error'

what am I doing wrong?

Thanks,

Jim

Excel Cell Value Is Not Empty
Hello,

Sometimes I do not understand simple things but maybe somebody else. I'am testing a cell value but I do not understand why the if statement is true:

if (IsNumeric(trim(wshSubnet.Cells(i, wshSubnet.Range("DBB_CB_NAME"& i).Column))) and _
(cint(trim(wshSubnet.Cells(i, wshSubnet.Range("DBB_CB_NAME"& i).Column))) > iCountInstal )) Then

Now: the value of the Cell is 2; iCountInstal = 2
DBB_CB_NAME"& i is a cell name

What I do not understand how can this be True? Because in my opinion the the value of the cell is 2 and is not bigger than iCountInstal which is 2 as well. The same problem do I have when the value of iCountInstal = 1
I think I make somewhere a stupid mistake but I don't see where

Must I do a type conversion first?

Nico

Excel Programming: Empty Cell Problem
Hey guys.
I've got a bit of a problem on my spreadsheet (an A-level ICT project, where we have to basically make a functional program in excel).

Lets say I label a cell 'username'. This is a user input box, and I'll print that same information on a different sheet in the same workbook.
However, the problem is, that when the user doesn't enter anything, it displays 0. I don't want this to happen.
Therefore, would it be possible to display a dialog box if the user left the cell blank? Or is there any other solutino that you could offer?

Thanks for your help.
-aJ

Howto Find Next Empty Cell In An Excel Worksheet?
Hi!

I'm making this program that writes to an excel file to keep a summary of information. I used the Excel object library as a reference and I can open the excel file.

My problem is how can I find the next empty cell in a column so I know where to append the next information?

Hope someone can help....

Thanks!!

VBA: Excel Macro: Copy Formula Down In Sheet2 Until Cell In Sheet1 Is Empty
I am trying to modify a soon to be recorded macro in Excel. I receive a file every month with X number of rows. I need to copy a formula that references a cell in Sheet1 down Sheet2 until there are no more rows to copy in Sheet1 (until the row to be copied is empty).

I found Do ... Loop Until, but I can only get it to work by testing a cell on the same sheet b/c the example I found uses ActiveCell.
Code:

Do
ActiveCell.FormulaR1C1 = "=Average(RC[-1],RC[-2])"
ActiveCell.Offset(1, 0).Select
Loop Until IsEmpty(ActiveCell.Offset(0, 1))

How can I test the cell on another sheet that's in the same row as ActiveCell?

I'm not asking for a handout, but they're always appreciated

Track Cell For Highlight Based On Cell Itself, Not Row Number
I am highlighting a cell in each row as that row is selected, and 'un'-highlighting the previous one. Right now I'm doing it based on the row number, but a problem occurs when I sort my columns. Obviously, after the sort, the row number of the highlighted cell changes and this makes the previous row and the current row the same sometimes, so it doesn't take the backcolor off when it should. Is there a way to keep track of which is highlighted by the cell itself, instead of the row number?

Cannot Distinguish An Empty Cell From A Cell Having A Value Of 0
guys i need some help on this one,
i am comparing two cells in excel, however
if the value of the first cell is 0 (zero) and
the other cell has no value the resulting
value is true...
meaning comparing 0 and an empty cell evaluates to true,
how is this possible, how can i make this expression
to evaluate to false???

hanks.

Highlight A Cell
how to highlight a selected cell in flexgrid control ?

Highlight Only What Is Written In A Cell
How can I highlight ( with some color ) only what is written in a cell instead of coloring the whole cell

please help

varrey

Highlight Cell Of MSFlexgrid
hi all

I am using MS Flexgrid to display data..
Well I am able to highlight particular cell
but for some critical values i need that
the backcolor of the particular cell should
get 3-4 color one by one......colorful blinking

how to do this...pls help

thanks in advance

How Do You Highlight A Cell In The Datagrid?
I've been desperately trying to figure out how to highlight a cell in the Datagrid control. All the solutions I could find in the forums and at the MS website involve using .SelStartRow & .SelEndRow, neither of which seem to be supported by VB6 (service pack 5.0) any longer (I get errors that I'm trying to use an "Unknown Property or Method" when I include them). Is there a way around this or a way to enable the .SelStartRow & .SelEndRow properties?

Last Empty Cell
What I want to do is to simply take the data from the last cell, copy it and then paste it 5 cells down. If I use the code below the computer hangs every time. What am I doing wrong?


Code:

Cells(Rows.Count, 1).End(xlUp).Offset(0, 0).Row

Range(Cells).copy

Range(cells + 5).Paste

Next Empty Cell
Hey guys and gals...

should be simply but not working too well...

I have UserForm1 with 5 info boxes accross

that is the same 12 times down the form..

All I am trying to do is write info from the UserForm (on button click) to the next empty cell from a starting row...

Get A Next Empty Cell
I have a prog using which I can open an existing Excel file and then send the date from it to new created Excel file. But here I have a problem on passing to another cell.
I mean how can I go to the next empty Row after I entered the date?
Let's see an example:
The first time when I click on SendButton the date will be placed on new created file in A1,B1,C1,D1,....est. the next time I will send the date I need it to go to A2,B2,C2,D2,....est.

How can I learn the next empty Cell

Private Sub SendButton_Click()

Like what steps I need to go here to learn
the next empty row

ws.Cells(1, 1) = txtName.Text
ws.Cells(1, 2) = txtAmount.Text

End Sub

Any idea appreciated!

Highlight Cell In MsFlexgrid - Urgent
Hi

i am using an msflexgrid to enter information. I have done this by determining what cell the user is in and placing what they type into the particular cell. My problem is that I need to highlight a single cell, sort of the same way you would highlight the words in a textbox (txt.sellength = len(txt)). I am not even sure if this is possible. the msflexgrid doesnt have the sellength and selStart properties available so i am stuck. if anyone knows how to do this it would be greatly appreciated.


any advice/help/recommendations would be greatly appreciated

Highlight Cell In MsFlexgrid - Urgent
I have created a table with six columns and with a different number of rows. I'd like to select a complete row and highlight it with a different color. All columns should be marked with a different color.
I´ve tried FlexGrid.RowSel and ColSel But I can´t manage to select one complete row.

Does anyone have any ideas about how it could be done?

/Anders

How Can I Keep The Selected Cell Highlight (msflexgrid)
Hi all,

When I select a cell in msflexgrid it will highlight, but when this compoent lostfocus all the cell will change the colour like unselect

How can I keep it highlight even the component lost focus?

Thanks

Highlight Cell Chosen In Database
I have a working program where I input a name to search in database. The grid control is tied to a Access table. Once I find the name in the database I want the name on the grid to be the active cell and highlighted. This is the code I have so far: Help!

Option Explicit
Private Sub cmdQuit_Click()
End
End Sub

Private Sub Form_Load()
MSFAddress.Row = 0
MSFAddress.Col = 0
MSFAddress.Text = "Name"
MSFAddress.Col = 1
MSFAddress.Text = "E-Mail Address"
MSFAddress.ColWidth(0) = 3000
MSFAddress.ColWidth(1) = 5000
MSFAddress.FixedAlignment(0) = flexAlignLeftCenter
MSFAddress.FixedAlignment(1) = flexAlignLeftCenter
MSFAddress.ColAlignment(0) = flexAlignLeftCenter
MSFAddress.ColAlignment(1) = flexAlignLeftCenter
MSFAddress.Rows = 1
ADOEmail.Refresh
frmEmail.ADOEmail.Recordset.MoveFirst
While ADOEmail.Recordset.EOF = False
MSFAddress.AddItem ADOEmail.Recordset.Fields("Name") _
& vbTab & ADOEmail.Recordset.Fields("EmailAddress")
ADOEmail.Recordset.MoveNext
Wend
ADOEmail.Recordset.MoveFirst
End Sub

Private Sub Text1_LostFocus()
MSFAddress.Col = 0
Dim MyAnswer As String * 40
Dim MyCriteria As String * 40
MyAnswer = UCase(Text1.Text)
MyCriteria = "Name ='" & Trim(MyAnswer) & "'"
ADOEmail.Recordset.MoveFirst
ADOEmail.Recordset.Find MyCriteria

If ADOEmail.Recordset.EOF = True Then
MsgBox "No such person on email list, try again.", vbCritical + vbOKOnly, "Email"
ADOEmail.Recordset.MoveLast
End If
End Sub

VBA Sub To Delete A Row If A Cell Is Empty
Hello Iam a newbie VBA user.
I have a spreadheet with several rows. Some of teh cells within the rows are blank. I am trying to write a subroutine that will look for a specif cell in a row (say B2) and if it is blank delete the entire row.

The code below will work if a ROW is empty but I am trying to refine it such that I select a range of Cells and if the cell is empty delete the entire row

Sub DeleteEmptyRows()
LastRow = ActiveSheet.UsedRange.Rows.Count
Application.ScreenUpdating = False
For r = LastRow To 1 Step -1
If Application.WorksheetFunction.CountA(Rows(r)) = "" _
Then Rows(r).Delete
Next r
End Sub

Any suggestions?

Finding The Last Empty Cell
I'm struggling to find an empty cell. I'm using:


Code:
intRow = Cells.Find(What:=IsEmpty(),LookIn:=xlValues,SearchOrder:=xlByRows)
I need to know what to put in the IsEmpty bit.

Any ideas?

Fill Next Empty Cell
Hello Everyone,

I have read alot of posts on this topic but I couldnt find one that worked for me, hopefully someone can help me out.

I have a userform in MS Excel in which when a user presses the command button it will fill in data on my WorkSheet1. The data that will be entered is Company Name, Customer Name, Address, Address2, City-State-Zip.

If every field had data in it when the user hits the command button then it would look something like this below on the worksheet:

Cell ("C11") = Company Name
Cell ("C12") = Customer Name
Cell ("C13") = Address
Cell ("C14") = Address2
Cell ("C15") = City, State Zip

However sometimes the Address2 field (which mainly has P.O. Boxes) is empty cuz not every company has a P.O. Box.

When this is the case I would like all the data below this to shift up and fill in the void for that empty field. Same goes with any other field that does not contain any values when the user hits the command button.

Any help is greatly appreciated,
Kind Regards

How To Determine Is A Cell Is Empty?
Hi Everybody

Since the function IsBlank() doesn't work with VBA, is the only way to test whether or not a cell is emtpy is to either of these (shown below) or is there is a built-in Excel function in VBA equivalent to IsBlank().


Code:
'Assume that cell(A1) on the Sheeet1 is blank - nothing has been entered in it yet.

Sub testing()
Dim myrange As Range
Set myrange = Worksheets("Sheet1").Cells(1, 1)
Dim test1 As Variant
test1 = myrange.Value 'test1 returns Empty
Dim test2 As Boolean
test2 = IsEmpty(Worksheets("Sheet1").Cells(1, 1).Value) 'test2 returns True
End Sub


Best regards


Deepak Agarwal

To Select An Empty Cell
In order to select a value before a blank cell, I get this command from other topic:

myvariable = Range("C5").End(xlDown).Row

unfortunately if the cells contain a formula like this:

=IF($C55="";"";........)

the above command not recognize no empty cell until that do not end the formulas introduced

In few word I need to modificate the command, inserting a control if cell is empty, or something like this, and not if is blank.
Someone could write to me this simply (I hope) solution ?
Thanks to everybody.

Empty Cell Verify...
Need to verify that a cell contains no text or value before a VB routine over-wrights it.

I need a little help here, most of the folks that are acquainted with me say that I’m beyond help. All of the cells contain formatting, but none contain text or values on the test sheet, every time the error trap routine (If Not ("C" & RW) = "" Then GoSub FullRoutine) runs it tells me that the cell contains data but isblank() returns true. This is way beyond my comprehenson, haven’t scrached code in a lot of years, usually just record it and hope for the best. But need a little something more here.

Sheets("new").Select
Range("A31:J36,B33,B34,A36").Select
Range("A36").Activate
Selection.ClearContents
Range("A27").Activate
RW = Range("A27") + 1
Range("A36") = RW
Sheets("2005").Select
Range("B" & RW).Select
Range("B" & RW).Activate
If Not ("B" & RW) =””Then GoSub FullRoutine
Range("C" & RW).Select
Range("C" & RW).Activate
If Not ("C" & RW) = "" Then GoSub FullRoutine
Range("A27:I27").Select
Selection.Copy
Sheets("2005").Select
Range("A" & RW).Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Stop
FullRoutine:
Sheets("new").Select
Range("A33").Select
ActiveCell.FormulaR1C1 = "STOP"
Range("B33").Select
ActiveCell.FormulaR1C1 = "Are You Sure Someone's not in this unit?"
Range("B35").Select
End
End Sub

Nex Empty Cell In Range
If I have the range A1:A65536, how do I search that range and activate the next empty cell below within the range ?

Paste To An Empty Cell
My question must have been answered before... but I just can't find the thread...

how can VB paste into an empty excel cell, without producing the "paste method out of range" error?

-jb

How To Avoid Empty Cell?
Hello, Everyone,
If there is some empty cell in 18 column, it won't return the last Row number. Is there a way to solve it?
Thank you very much!
Charlie

Code:
nLastRow = xlApp.Worksheets("sheet1").Cells(65536, 18).End(xlUp).Row

Detect Empty Cell
I'm writing a macro ( actually 2 macros, one for character, one for numeric ) that allows the user to override an exsiting value calulated elsewhere in the spreadsheet. As a first step, I want to detect when/whether the user has entered a value or not.

I thought that something like

mycheck = IsEmpty(Override)
If mycheck = -1 ( or NULL ) Then .....

would tell me that when the user DID NOT enter something ( or had deleted what he did enter ). However, even when the cell is empty ( and confirmed by ISBLANK in Excel ), I can't detect when the cell is empty.

hope this isn't a really stupid queston .

thanks in advance for your help

regards
woody

Empty Cell Test
Guys,
How would you test a column for a empty cell, then once you have found your empty cell, mark that as being empty then go back up one and select from top of the column to the variable defined bottom of that column. Any help would be appreciated. Thanks!

Empty Cell In Graph
Hello,
Facts:
Column A are X axe of a graph. Column B is the Y axe of the graph.
If the cell B3 equal zero or some texte, the graph will show a point at zero. But if B3 is empty, the graph will not show the point at all.
Question?
My cell B3 contain a formula, which return "" if false. Excel recognize "" as empty cell, but the graph show a point at zero! I would like either:
-to find a way that the graph do not show the point when the cell got "" as value.
-to find a way in the formula to return an empty cell (carriage return?)
I have already tried to play with the graph options with no luck. I am trying not using VBA.
Thanks in advance,
Chib

How To Emulate A Really EMPTY Cell?
Hi folks,

I can't find a solution for my problem. Excel treates empty cells very special and I want to have this behavior for cells containing following function:

Public Function NumOnly(r As Range) As Variant
' r referes to cells containing numbers of any kind -> return this number
' otherwise make the cell appear empty
' (event to Excel: e.g. Charts or AVERAGE)
Dim c As Range ' For Each c

Application.Volatile ' always recalculate

For Each c In r.Cells
Select Case VarType(c.Value)
Case vbInteger, vbLong, vbSingle, vbDouble ' numbers only
NumOnly = c.Value
Case Else ' otherwise empty
' NumOnly = CVErr(xlErrNA) ' #NV doesn't do what I want
' Set c.Value = Empty ' this in turn doesn't work
End Select
Next c
End Function

It is not enough to return "" because charts would just draw a value of 0 and AVERAGE would sum up this cell, too. The porblem is that the cell can't be empty as such, since it contains a formula (e.g. "=NumOnly($A$1)"). But how can I make Excel behave like it was empt? With the #NV-solution I could get by (sort of) but line charts wouldn't leave a gap where the empty cell should be and AVERAGE would return #NV, too.

Please help

AndyR

Giving A Cell An 'empty' Value
I want to include an IF statement in one of my cells and I want to have an 'empty' value, that is, the same as if i had just pressed delete to wipe the contents of that cell. How can I integrate this into my EXCEL formula?
Thanks,
Rob

Find First Empty Cell
I am using VB to open a worksheet and find a value within a cell. From there I need to read every cell until I get to the first blank cell. If I know the column and row to start from in question how can I find the first row in that column that is empty.

How To Determine If A Cell Is Empty
I'm attempting to create a macro that will delete an entire row if the gift
amount is less than $99 and the comment field is blank.

'Delete row for all gifts under $100 and comment field is empty
giftcount = 1
Set xRng = Selection
Range("A2").Select
For giftcounter = 2 To FinalRow Step 1
If Cells(giftcount, 89).Value <= 99 Then
If Cells(giftcount, 96) = "" Then
xRng.Cells(giftcount).EntireRow.Delete
Else
giftcount = giftcount + 1
End If
Else
giftcount = giftcount + 1
End If
Next giftcounter

Thanks,
Dorie

********************************************
"Success is to be measured not so much by the position
that one has reached in life as by the obstacles which he
has overcome while trying to succeed.
-- Booker T. Washington

Need To Highlight The Formula In A Cell And Press Enter
Hey, I'm attempting to update some 9 year old code. It's not written very well, but I don't have time to totally redo it, so I'm trying to work with it. Currently, I have a loop that fills cells up with formulae. Now, unfortunately, when I run the code (Excel VBA), all the cells are filled up with #NOM? (French Excel... Nom = Name). Now then, when I click on a cell, go to the end of the formula and press enter, it works fine.

So how do I get the code to do this? I tried recording a macro, but when I copy that code into my loop, it runs me out of memory. Here's the loop:


Code:
For nIndex = 18 To 185
With Sheets("qh_1line").Cells
.Item(nIndex, 2).Value = "=+qh!Y" & nIndex - 12
.Item(nIndex, 3).Value = "=SI(B" & nIndex & "=" & Chr(34) & Chr(34) & "," & Chr(34) & Chr(34) & ",+B" & nIndex & "*0.3048)"
.Item(nIndex, 4).Value = "=SI(B" & nIndex & "=" & Chr(34) & Chr(34) & "," & Chr(34) & Chr(34) & ",+E" & nIndex & "/$C$5)"
.Item(nIndex, 5).Value = "=SI(B" & nIndex & "=" & Chr(34) & Chr(34) & "," & Chr(34) & Chr(34) & ",+$C$5*(C" & nIndex & "/10)^0.2)"
.Item(nIndex, 6).Value = "=SI(B" & nIndex & "=" & Chr(34) & Chr(34) & "," & Chr(34) & Chr(34) & ",0.12919*(($C$8*EXP(-$C$9*C" _
& nIndex & ")+$C$10*LN(C" & nIndex & "/$F$8)/LN(C" & nIndex & "/$F$9))*$F$10)^2*(C" & nIndex & "/10)^0.2)"
.Item(nIndex, 8).Value = "=SI(B" & nIndex & "=" & Chr(34) & Chr(34) & "," & Chr(34) & Chr(34) & ",+E" & nIndex & "*0.0209)"
.Item(nIndex, 9).Value = "=SI(B" & nIndex & "=" & Chr(34) & Chr(34) & "," & Chr(34) & Chr(34) & ",+F" & nIndex & "*0.0209)"
.Item(nIndex, 11).Value = "=SI(B" & nIndex & "=" & Chr(34) & Chr(34) & "," & Chr(34) & Chr(34) & ",+I" & nIndex & "/H" & nIndex & ")"
.Item(nIndex, 13).Value = "=SI(B" & nIndex & "=" & Chr(34) & Chr(34) & "," & Chr(34) & Chr(34) & ",+I" & nIndex & "/$C$5)"
End With
Next

Now here's what the Macro gives me:


Code:
Range("C18").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-1]="""","""",+RC[-1]*0.3048)"

Highlight Single Cell In MSFlexgrid (Resolved)
I would like to be able to select a single cell in MSFlexgid on a click event and highlight it.
A selection (click) on another cell should de-highlight the first cell. That is, at most one cell should be hoghlighed at once.

I'm just getting into working with VB GuI's, so this might be very simple..

Thanks for any help



Edited by - SuperSonicVB on 8/16/2004 8:00:54 AM

Some Help Needed {check If Cell Is Empty}
Hi.

I'm new here. I hope this is the right place to put this.

I am very new to visual basic, and the one I'm using atm is the one from Excel 97.

This is the code I need hlp with.

If Range("D7") Then

I have no idea how to say this but what I want is basically, if the cell D7 has any kind of text/numbers etc. then i want it to etc. The trouble is I don't know what to put inbetween Range D7 and Then to say if the cell has any text/numbers.

Can anyone help me please.

Selecting A Range {until Empty Cell}
Hi

I'm trying to write code that will select a range of cells (in column A) but will stop selecting once an empty cell is detected.

I'm not sure if this code should include a do-until loop?
I would greatly appreciate any help.
Thanks

Making A Do While Loop Until Empty Cell
How do i make a do..while.. loop until it reaches an empty cell in column x?

thanx

Empty Cell/clear Row If Doesn't Contain #
Hi everyone,

I'm looking for some help here. I have an excel worksheet and I'm trying to find out if this is possible.

I need to have Column C checked to see if the cell contains a "#", if not to empty the row.

Then I need to check again if Column C has empty cell, to delete that entire row.

I need to do the empty Colum C cell first because some rows with only Column A filled with text (no #) need to stay put.

Is this possible? Can someone with some macro knowdledge kindly lend a hand?

Thanks so much in advance!

Error If Reading Empty Cell.
When ever my program hits a cell that is empty in my database, it crashes and says "invalid use of Null."

Anyway for me to keep it going?

Or am I going to have to redesign my database to fill every cell?

Unable To Highlight Flexgrid Fixed Column/Cell
I have a MSHFlexGrid with one fixed row and two fixed columns. SelectionMode is set to flexSelectionByRow. When selecting a row in the grid all of the columns/cells for the select row are highlighted except for the fixed columns/cells. Is there a way to also highlight the fixed column/cells for the selected row?

AlanG

Need Help To Find The Last Non-empty Cell In A Column Dynamically
Hi!
I need to get the value in the last filled cell of a column. My cells in the column have values - either TRUE or FALSE or <blank>. I need to get the last cell value in the column (only the TRUE and FALSE, I don't need to take in the blanks).

Column NumberValue
C27FALSE
C28FALSE
C29TRUE
C30FALSE
C31FALSE
C32FALSE
C33FALSE
C34
C35


Does anybody have any suggestions?



There's one more thing. The values are in Column C (let's say). And whenever there is a change in the worksheet, the cells keep being filled downwards. Now, I need to get the last value of the column and put it in say J2. This cell J2 should keep getting updated with the latest value. I don't want to have the formula repeated downwards. The last
filled value in the cell (which keeps changing dynamically - the ranges change dynamically) should be updated in cell J2.

For example, first the cells C2 to C5 are filled with True or False. The rest of the cells are <blanks>. So, I want the value of C5 to be in J2.

Next, the cells filled will be C2 to c8. Then I need the value of cell C8 to be in J2.

Let me also tell you that Cells in column C are filled based on the formula - =IF(G23<>" ",AND(G23=1,F23=0),"")

Thank you!

Davy

Avoid Date Type Cell Empty?
Hello, Everyone:
My data cell is date type string. When it is empty, the default is 12Am. How can I avoid? It is possible for me to replace it visit most recent time in which cell is near it? Any good suggestion to program it in VBA? Is there any way to avoid this default value?
Thank you very much!
Charlie

Cell.Find Returns Error When EMPTY Is Detected
Hi there, I am trying to do a looping. On the user front, it is supposed to perform a find cell containing 'Box ID' and from there, delete fixed no. of rows from the top. However problem arises when find returns EMPTY coz there is no more cell containing 'Box ID'. How to I troubleshoot this error? Thanks for your help in advance!




Code:
indResultA = Cells.Find(What:="Box ID", After:=ActiveCell, LookIn:=xlValues, LookAt:=xlWhole, _
SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _False, SearchFormat:=False).Activate

Do While findResultA = True

Range(ActiveCell.Offset(1, 0), ActiveCell.Offset(-10, 0)).EntireRow.Select

Selection.Delete Shift:=xlUp

'Macro detects error if no more cell is found and error is found in VB.
findResultA = Cells.Find(What:="Box ID", After:=ActiveCell, LookIn:=xlValues, LookAt _:=xlWhole, _
SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _False, SearchFormat:=False).Activate

Loop


Edit by Moderator:
Please post Excel questions, in the Excel forum.

Please use the [vb][/vb] tags when you post your code. Edit or reply to this post to see how.

Thank you.

Replace DB Null So That HTML Page Creates An Empty Cell
I use this code to convert a DB table to an HTML page but the only way I can get it to create a cell where the returned value is NULL is to use the "_", but I just want an empty cell. If I use "" then the cell is not drawn on the HTML page. What can I substitute instead of the "_"?
Code:

Private Sub Form_Load()
Dim oConn
Dim rs
Dim fso
Dim outhtml
Set fso = CreateObject("Scripting.FileSystemObject")
Set outhtml = fso.CreateTextFile("c:userdumpChoice_Report.htm", True)

outhtml.WriteLine "<html>"
outhtml.WriteLine "<body>"
outhtml.WriteLine "<table border=1>"


Set oConn = CreateObject("ADODB.Connection")

oConn.Open "Driver={Microsoft Access Driver (*.mdb)};" & _
            "Dbq=C:Documents and SettingsJulianMy DocumentsNHDSChoiceChoice.mdb;Uid=Admin;Pwd=choice2openZZZ;"

Set rs = oConn.Execute("SELECT * FROM tblClient")

  outhtml.WriteLine _
        "<tr><td>" & rs.Fields(1).Name & "</td><td>" & _
                        rs.Fields(2).Name & "</td><td>" & _
                        rs.Fields(3).Name & "</td><td>" & _
                        rs.Fields(4).Name & "</td><td>" & _
                        rs.Fields(5).Name & "</td><td>" & _
                        rs.Fields(6).Name & "</td><td>" & _
                        rs.Fields(7).Name & "</td><td>" & _
                        rs.Fields(8).Name & "</td><td>" & _
                        rs.Fields(9).Name & "</td></tr>"
Do While Not rs.EOF
  outhtml.WriteLine _
        "<tr><td>" & IIf(IsNull(rs.Fields(1).Value), "_", rs.Fields(1).Value) & "</td><td>" & _
                        IIf(IsNull(rs.Fields(2).Value), "_", rs.Fields(2).Value) & "</td><td>" & _
                        IIf(IsNull(rs.Fields(3).Value), "_", rs.Fields(3).Value) & "</td><td>" & _
                        IIf(IsNull(rs.Fields(4).Value), "_", rs.Fields(4).Value) & "</td><td>" & _
                        IIf(IsNull(rs.Fields(5).Value), "_", rs.Fields(5).Value) & "</td><td>" & _
                        IIf(IsNull(rs.Fields(6).Value), "_", rs.Fields(6).Value) & "</td><td>" & _
                        IIf(IsNull(rs.Fields(7).Value), "_", rs.Fields(7).Value) & "</td><td>" & _
                        IIf(IsNull(rs.Fields(8).Value), "_", rs.Fields(8).Value) & "</td><td>" & _
                        IIf(IsNull(rs.Fields(9).Value), "_", rs.Fields(9).Value) & "</td></tr>"
  rs.MoveNext
Loop

outhtml.WriteLine "</table>"
outhtml.WriteLine "</body>"
outhtml.WriteLine "</html>"
outhtml.Close

End Sub


|
+--JDMils
|
+--VB6
+--VB Dot Net
|
+-- Navman GPS Forums @ http://forum.jdmils.com
|


Edited by - JDMils on 5/11/2007 2:03:41 AM

Excel - Making A Cell Equal To The Value Of The Formula In The Cell
I thought I'd seen something on this already, but I coudln't find it. My appoligies if I'm creating a duplicate thread.

I'm writing a macro in excel to fill in data in a database. Unfortunately, my titles for each entry have to be taken from multiple cells and put into one cell. The code to place the title in the title cell is:

Code:Dim title As String
    title = inputname & "!$B$3, " & inputname & "!$C$3, " & inputname & "!$D$3, " & inputname & "!$E$3, " & inputname & "!$F$3, " & inputname & "!$G$3, " & inputname & "!$H$3, " & inputname & "!$I$3"
    title = "=CONCATENATE(" & title & ")"
    ActiveCell.Value = title

It works fine. The problem I'm having is that every time I save and reopen my database excel pops up with this "The workbook you opened contains automatic links to information in other workbooks..." It's getting very annoying. And it also gives me problems if anybody touches the already filled title cells. I was thinking that there might be a way to make the formula equal to the value of the formula. For example making a cell have the value 4 instead of the forumula "=2+2". Thanks for any help.

How To Link An Excel Cell To An Access Table Cell
I am trying to import an populated excel form into access using just specific cells (where the data is located) only. I am able to open excel and get the data from the cells but how can i assign them back to my access table? This is like importing a populated excel form into access database.


I used these to get my excel info

Set excel_app = CreateObject("Excel.Application")
excel_app.Visible = False
excel_app.Workbooks.Open FileName:=mypathname & myfilename
Set excel_sheet = excel_app
x= excel_sheet.cells(10, 4).Value 'To get the excel cell value'
y= excel_sheet.cells(12,4).Value

Now I want x to be assigned to table "AppendTable" in column "AppColumn1"
and y in column "AppColumn2"

help!!!

Copyright © 2005-08 www.BigResource.com, All rights reserved