VB excel help needed

I need to write a macro for excel to do the following.

If cell d(n) is "" the copy r(n) into d(n).

anyone know what sub needs to be written?

Cheers

EggHeadCafe - Software Developer Portal of Choice 
COM+ Services Overhead in .NET
http://www.eggheadcafe.com/tutorials/aspnet/aab197cf-64da-4233-9819-02edbea0e9fb/com-services-overhead-in.aspx
0
Robert
11/27/2009 2:48:57 PM
excel.programming 6508 articles. 2 followers. Follow

4 Replies
745 Views

Similar Articles

[PageSpeed] 55

Assuming we are talking about running this code against the ActiveSheet and 
that d(n) means you are referring to the Nth row in Column "D", then I think 
you may be looking for this construction for your code...

If Cells(n, "D") = "" Then Cells(n, "D").Value = Cells(n, "R").Value

-- 
Rick (MVP - Excel)


"Robert Bloom" wrote in message news:2009112794851robertpbloom@aol.com...
>I need to write a macro for excel to do the following.
>
> If cell d(n) is "" the copy r(n) into d(n).
>
> anyone know what sub needs to be written?
>
> Cheers
>
> EggHeadCafe - Software Developer Portal of Choice
> COM+ Services Overhead in .NET
> http://www.eggheadcafe.com/tutorials/aspnet/aab197cf-64da-4233-9819-02edbea0e9fb/com-services-overhead-in.aspx 

0
Rick
11/27/2009 3:07:25 PM
A friend emailed me with this;
If i < 10 Then
  document.write("Cell NO")
Else
  document.write("Cell No2")
End If

does this help me?

i admit i'm a complete novice



Robert Bloom wrote:

VB excel help needed
27-Nov-09

I need to write a macro for excel to do the following.

If cell d(n) is "" the copy r(n) into d(n).

anyone know what sub needs to be written?

Cheers

Previous Posts In This Thread:

EggHeadCafe - Software Developer Portal of Choice 
Using the MS Text Driver to read Delimited  Files
http://www.eggheadcafe.com/tutorials/aspnet/c77b7a8d-5240-402e-b5c2-3895d1a2df28/using-the-ms-text-driver.aspx
0
Robert
11/27/2009 3:09:58 PM
Perhaps the description of what actually needs to be done could be a
bit better but from what you've posted - something like this could be
a start:

Sub PutOneCellValueIntoAnother()
  Dim rngTarget as Range
  'Here it's assumed that your d(n) is Range("A1") and your r(n) is
Range("A2").

  Set rngTarget =3D Range("A1")

  if rngTarget.value=3D"" then rngTarget.value=3DRange("A2").value

End Sub

But as above - you'd need to describe better what you actually need to
get more meaningfull advices here.

On Nov 27, 2:48=A0pm, Robert Bloom wrote:
> I need to write a macro for excel to do the following.
>
> If cell d(n) is "" the copy r(n) into d(n).
>
> anyone know what sub needs to be written?
>
> Cheers
>
> EggHeadCafe - Software Developer Portal of Choice
> COM+ Services Overhead in .NEThttp://www.eggheadcafe.com/tutorials/aspnet=
/aab197cf-64da-4233-9819-0...

0
AB
11/27/2009 3:13:42 PM
you mean, if cell d(n) is empty, then copy cell r(n)
into cell d(n)??

Here's my guess:

If IsEmpty(Range("D1")) Then
  Range("D1").Value = Range("R1").Value
End If


"Robert Bloom" wrote in message news:2009112794851robertpbloom@aol.com...
>I need to write a macro for excel to do the following.
>
> If cell d(n) is "" the copy r(n) into d(n).
>
> anyone know what sub needs to be written?
>
> Cheers
>
> EggHeadCafe - Software Developer Portal of Choice
> COM+ Services Overhead in .NET
> http://www.eggheadcafe.com/tutorials/aspnet/aab197cf-64da-4233-9819-02edbea0e9fb/com-services-overhead-in.aspx 

0
Robert
11/27/2009 3:54:52 PM
Reply:

Similar Artilces:

VB distmon?
Hi I have recently installed Office 2003. A couple of wired things happen in Excel: > Everytime I close the program I get a MS VB error that reads "Compile error in hidden module: Distmon" Every time open the program I get the same error, but the macro it is calling is "autoexecnew" > Since my new installation, I type in an simple function like TRIM and it tells me cannot find project library. any ideas? Thnaks! Alan Alan http://support.microsoft.com/default.aspx?scid=kb;EN-US;q307410 OFF: "Compile Error in Hidden Module" Error Message When You Sta...

HELP: retreiving forgotten passwords from Outlook
I've got Outlook 2003 and got a POP3 mail account set up. However I want to do a fresh installation of Windows and will lose my account details. I do not remember my password and was wondering how can I retreive my password for the "Logon Information" and also "More Settings | Outgoing Server" passwords. Since the passwords are in ****** format. I assume the passwords are stored in Outlook files encrypted right? KevinGPO, you wrote on Thu, 15 Dec 2005 09:20:48 -0000: > I've got Outlook 2003 and got a POP3 mail account set up. However I want to > d...

Excel Guide
Hi all, I'm new of this group and of Excel too.. I'd like to find a good excel guide online.(pdf preferred)Any good link I should visit?? Thanks Rossella Hi Rossella, I send some link that may be helpful using excel http://www.internet4classrooms.com/on-line_excel.htm http://www.usd.edu/trio/tut/excel/ http://www.baycongroup.com/el0.htm http://einstein.cs.uri.edu/tutorials/csc101/pc/excel97/excel.html http://www.bized.ac.uk/timeweb/excel.htm "Rossella" <rossy77@gmail.com> wrote in message news:1136988163.221379.137300@f14g2000cwb.googlegroups.com... > Hi all, &...

Excel 2007; graph the best fit line from a regression analysis?
Try using this white space to ask you question with a bit more detail best wishes -- Bernard V Liengme Microsoft Excel MVP http://people.stfx.ca/bliengme remove caps from email "mattz" <mattz@discussions.microsoft.com> wrote in message news:574CCC66-72EA-44D0-8D36-2147B6C7C279@microsoft.com... > ...

Formula help #13
E2 = A VALUE IN DOLLARS I2 = A NUMBER IN PERCENT need formula to make F2 = number that would make F2+(F2*I2)= E2 EXAMPLE E2=$11.99 I2=40% THEN F2= 8.56428571428571 using goal seek Thanks -- Carl Brehm Lake Lafourche Bird House Hebert, LA Keets, Tiels, GN Lories, Quakers Mitred Conures, TAG's, Bourkes Cages --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.581 / Virus Database: 368 - Release Date: 02/09/2004 F2 is =E2/(1+I2) you might want to round that -- Regards, Peo Sjoblom "Carl Brehm" <cr...

Excel VB
I have two cells in a workbook that are dates. The cell Start_Date has a valid date in it. The second cell Test_Date is either blank or has a valid date in it. The IsDate test on both cells works fine, however, on a blank cell the Month function extracts "12". Anyone know why? I had to put the month function within a test for IsDate to make it work. Seems like Month function on a blank cell should return something other than a 12. Dave Test code: If IsDate(Range("Start_Date")) Then 'Cell has 11/01/09 in it. MsgBox ("start date a d...

Can't find the file in Excel unless I open it from Excel
Can't find the file in Excel unless I open it from Excel -------------------------------------------------------------------------- I have a stange problem that has just started. I am running Windows XP and Office XP. If I click on an Excel file in my folders in explorer, it will open Excel and an error message comes up telling me it can't find the file and to check the path and folder. Once I click out of the message the file sometimes is already open. I have no problems if I open Excel first then open a file - it is driving me crazy, please help. Tr...

Cannot Add any window to VB
Hello: I'm using a VM with GP 10.0 SP3 installed. In order to have the same as our production databases i copy the GP folder, entirely, which i think it was a mistake now I'm getting a "This cannot be added to Visual Basic", whenever i try to add a window, any window, to VB. Also it goes without saying that there's a lot of load errors starting GP. For the record the copy/paste thing worked, sort of, and before you start thinking that i was insane to have done this, there's a reason behind it, There's been a lot of tweaks to our production server, by our p...

How do I keep duplicate text from being entered in an excel file?
I am entering product names in excel (in the hundreds) and I would like to have excel check that as I enter a name it has not already been used. Hi Select the column with product names, and goto Data > Validation > Allow: Custom > Formula: =CountIf($A:$A,A1)=1 Hopes this helps ... Per "Ed Green" <Ed Green@discussions.microsoft.com> skrev i meddelelsen news:509170E8-C641-435F-9DAC-1C144A7D154F@microsoft.com... >I am entering product names in excel (in the hundreds) and I would like to > have excel check that as I enter a name it has not al...

backing up Excel workbooks.
At work we have several extensive Excel worksheets. Is there a way to automatically create a backup of these files? Thanks ahead of time for any help in this matter. Primepixie Here is what I use in addition to the autosave feature Sub Backup() 'kept in personal.xls & assigned to toolbar button On Error GoTo BackupFile MkDir CurDir & "\Backup" BackupFile: With ActiveWorkbook MyWB = .Path & "\BACKUP\" & .Name .SaveCopyAs MyWB .Save End With End Sub -- Don Guillett SalesAid Software donaldb@281.com "Primepixie" <Primepi...

Excel with Outlook Express
Dear Friends, Hope you can help me in this regard, my problem is that I want to send a Email (not as a attachment) to a certain persons from Excel automatically through Outlook Express. I have configured my Outlook Express. Details as Below: Excel2000 Outlook Express 6 From: abc@xyz.com Email To: xyz@abc.com Thanks in advance, regards, Suresh tp Best to check out www.rondebruin.nl/sendmail.htm -- HTH Bob Phillips "SURESH" <way2suresh@hotmail.com> wrote in message news:eBSdRekoFHA.1412@TK2MSFTNGP09.phx.gbl... > Dear Friends, > > Hope you can help me in thi...

vb from VC++
Hi, is it possible, and if so, to call a Vb macro from VC++. Or manipulate spreadsheets (ie draw graphs from the data within the workbooks) usinbg MFC functions cheers Anthony Presumably you are referring to MS Excel spreadsheets and workbooks. The easiest method would be to import the appropriate type library (.tlb) provided with Excel, having the class wizard generate the classes, which you then use to access the Excel Automation model (that is the same model that Excel VBA uses). Some investigation may be needed to determine which tlb to use, and to make sure you have a basic understand...

Excel config files
Installing Excel on a new computer, want to copy over the config files, not sure which these might be or where they're located. ? Thanks! Config files? "Steve" <kg@ut.inv> wrote in message news:5nnrovcg36i4ve5jivn2te86ac4g3j9tec@4ax.com... > Installing Excel on a new computer, want to copy over the config > files, not sure which these might be or where they're located. ? > > Thanks! "Steve" wrote... >Installing Excel on a new computer, want to copy over the config >files, not sure which these might be or where they're located. ? ...

Importing 23 Excel Datafiles to one Excel Datafile at The Click Of A Button
Hi, I'm stuck in Importing 23 Excel datafiles called " Data for State1 2009.xlsx",........,"Data for State23 2009.xlsx" to a single Excel Datafile called " Import.xlsx".All 24 datafiles are stored in asigle folder called Excel in location C of my computer. Kindly help me out. Kind Regards, siddharth Hi Sidhu If you want it easy try http://www.rondebruin.nl/merge.htm See also the code links on the bottom of the page -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "Sidhu Khanna" <sidhukhanna9@g...

Excell Glitch???
Excell 2002 version is changing the last number of my credit card accounts to 0!! Can I be doing something wrong? I am using Excell 2002. I created a list of my credit cards to keep track of them, and I just have noticed that in a column that I named credit card numbers, the last digit is changed to "0" !!! I customized to accept 16 numbers (####-####-####-####) which follow the credit card format account numbering. when I enter the numbers say 1111222233334444 I expected to get 1111-2222-3333-4444; however to my surprise I am getting 1111-2222-3333-4440, and it does not matt...

Excel
Is there some function in Excel (VBA) that will get me the column alphabet if I provide the column number, or do I have to write one. I ask because I know that there is, yet I recall I wrote this functionality for the previous application, and I don't want to: (1) Reuse it, if there's something in-built (2) Re-invent the wheel Help! PS: I'm looking for something like: code:-------------------------------------------------------------------------------- Function GetAlphabet(ByVal ColumnNumber as Long) as String ------------------------------------------------------------------...

Please help with VERY complicated Addition
I am creating a worksheet for work. Does anyone know how to do the following, or maybe it is not even possible. Example: WE are pilots, so we are trying to log who flew a particular leg. I have a name in cell A1 and A2 (both pilots) In cell A3, is the place that we enter the time it took to fly the particular leg In cell A4, I have the question "who flew this leg?", and it has a dropdown menu with the names of both pilots from Cells A1 and A2 and U must select only 1 name In cell B1 and B2 (cells next to each pilots name) is another place for the flight time (contents of A3...

help with format / formula
in C2, 2 choices (menu) Single or Multiple single refers to cells B8:D12 multiple to cells G9:J13 Until a choice is made both sets of cells remain blanked out (white text using conditional format) When a choice is made then that set of cells would show as black letters (using conditional format) but only the range of cells that the choice (single or multiple) refers to. Is it possible to achieve the above with conditional formatting. thanks "SS" <nonense50@blueyonder.co.uk> wrote in message news:MclUo.49596$WK5.27065@newsfe28.ams2... > in C2, 2 choices (menu)...

Export scheduled bills in to Excel?
Is it possible to export my scheduled bills in to a spreadsheet? I can print a list of all of my scheduled bills but it appears that I cannot save them to another file format? Thanks! nulabas MS Money 2000 ...

VB in Excel
In Excel I go into Visual Basic Editor, then Visual Basic Help, but when I type 'Passwords' for example it will bring up a list of related items, but some of them you can't select. Does this mean the installation CD is corrupt and hasn't installed all the components? I have reinstalled and repaired the installtion but to no avail. Any ideas anyone? Help! Thanks ...

Changing from Excel 2003 to 2010...?
At work, I shall shortly be upgraded from Office 2003 to 2010 as part of a general IT upgrade (albeit with no change in hardware for users). My colleagues and I use a large number of pretty complex, linked, spreadsheets with lots of macros etc. Many of these run from buttons on user created toolbars etc. I'm sure Excel 2010 is an excellent spreadsheet programme and we'll all get used to it in time... However, given the new ribbon UI etc I am a little anxious about whether our existing spreadsheets will still work properly (we can't afford any downtime). Obviously I will do ...

VB.Net program to create XML file
I need to create an xml file from a VB program using fields returned from an sql query. I have a template that was provided for me and need to use verbatim. Since this is just a text file, I gather that I can just write out the file with all of the tags, etc., and name it .xml. Assuming that is correct what I might want to do is create a template so that if this file changes the names of the elements, all I have to do is change the template and if more elements get added I can then add them. Is there a tool that can do this for me? If I have to create one, any suggestions as to what I ...

Excel icons
All my alias icons now have the excel icon on top of the alias icon. For example if I have an alias to a ppt presentation I can see the ppt icon underneath the excel icon.. If I try to change the icon by using the apple-I command followed by edit-paste onto the icon it makes no difference (all that happens is that the underneath icon changes) Have fixed permmissions - no difference Any ideas Lorry ...

Word Wrapping in Excel #3
I want excel to adjust the height of the row correctly -- Mandy1 ----------------------------------------------------------------------- Mandy11's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=1300 View this thread: http://www.excelforum.com/showthread.php?threadid=27632 If you've manually set the row height, choose Format/Row/Autofit to restore the default behavior. If instead you've got cells merged (which IMNSHO you shouldn't, but people do anyway), you'll need to use VBA. See Jim Rech's macro: http://google.com/groups?selm=uGMQV...

XP imcompatible with Excel 2007?
I noticed that if you compared Excel 2007 installed on Vista and Excel 2007 installed on XP, the font color of XP is lighter than Vista, besides, the background color of the toolbar also sightly different. This difference of font color in the excel content of two different OS is obvious especially when the font size is small. Any solution? ...