Excel Macro - Drag Cells

Microsoft OFFICE

    Sponsored Links

    Next

  • 1. How to Accessing field of MS-Word by Name instead of Index in VB.N
    Hi, I hvae one MS-Word document, which has some merge fields. in VB.NET i need to update these fields with data from DB. But while accessing i want to access the field by name instead of index. objSrcFromDoc.Fields.Item(1).Result.Text = "Data from DB". Here we are accessing by Index, but i need to access by field name. Is there any way. Please help me. Nirmal. XXXX@XXXXX.COM
  • 2. Automatic Summation
    Hi, I am creating an assignment sheet in word. At the end of each question there's the mark allocation. Ex: What is the capital of Canada? (3 marks) I would like to create a macro that will find all the marks and sum it together, and add the total at the end of the document. What is the best approach for this? I'm an experienced developer, but have no experience with VBA. So, any guidance will help. Thank you in advance!
  • 3. Accessing field by Name instead of Index
    Hi, I hvae one MS-Word document, which has some merge fields. in VB.NET i need to update these fields with data from DB. But while accessing i want to access the field by name instead of index. objSrcFromDoc.Fields.Item(1).Result.Text = "Data from DB". Here we are accessing by Index, but i need to access by field name. Is there any way. Please help me. Nirmal. XXXX@XXXXX.COM
  • 4. Modifying built in document properties using an excel macro
    I am having an interesting problem while trying to set the built in document properties of a word file using an excel macro. I am picking the values from an excel sheet and trying to set the values for each .doc file in a folder one by one. The following code runs perfect the first time and sets the new values for all built in properties for all the word files in the "C:\Test" folder. But when i run the code a second time with new values, it executes without any error but doesn't set the new values (the doc files have the old values itself). Can someone help please? Urgent.... Sub Macro2() Dim i As Integer Dim wordApp As Word.Application Dim wordDoc As Word.Document Set wordApp = CreateObject("Word.Application") With Application.FileSearch .NewSearch .LookIn = "C:\Test" .SearchSubFolders = False .Filename = "*.doc" .Execute For i = 1 To .FoundFiles.count ThisFile1 = Range("B" & i + 1).Value ThisFile2 = Range("C" & i + 1).Value ThisFile3 = Range("D" & i + 1).Value Set wordDoc = wordApp.Documents.Open(Filename:=.FoundFiles(i)) wordApp.ActiveDocument.BuiltinDocumentProperties("Title") = ThisFile2 wordApp.ActiveDocument.BuiltinDocumentProperties("Subject") = ThisFile3 wordApp.ActiveDocument.BuiltinDocumentProperties("Author") = ThisFile4 wordDoc.Save wordDoc.Close Next i End With End Sub

Excel Macro - Drag Cells

Postby JCO » Sat, 26 Jun 2010 07:42:44 GMT

Is it hard to change an existing macro from a hardcode selection so that the 
macro works over an area that you selected with the mouse?  Lets take 
something easy like changing the Case to Proper Case (first letter of each 
word is capitalized and all other letters are lowercase).

Sub ProperCase()
    'Loop to cycle through each cell in the specified range.
    For Each x In Range("C1:C5")
        'There is not a Proper function in Visual Basic for Applications.
        'So, you must use the worksheet function in the following form:
        x.Value = Application.Proper(x.Value)
    Next
End Sub

In this case, it is hardcoded for the range C1 to C5.  I would like to Drag 
and Select any area then run the Macro.
Is this possible?
Thanks 


Re: Excel Macro - Drag Cells

Postby Chirag » Sat, 26 Jun 2010 16:50:02 GMT

Change the Range("C1:C5") to Selection. The macro would look like:

Sub ProperCase()
    'Loop to cycle through each cell in the selected range.
    For Each x In Selection
        'There is not a Proper function in Visual Basic for Applications.
        'So, you must use the worksheet function in the following form:
        x.Value = Application.Proper(x.Value)
    Next
End Sub

- Chirag

  PowerShow - View multiple PowerPoint slide shows simultaneously
   http://www.**--****.com/ 







Similar Threads:

1.copy excel cell to cell in word table using excel macro

I have a macro in excel that copies a cell, opens a word document, moves the 
cursor to a specific location, then pastes what was copied.  After that it 
goes to a new location in the word document (which is in a table), goes back 
to the excel spreadsheet which is still active, copies a new cell then 
returns to the word document to paste that.  So far I have tried numerous 
coding to get the data to paste but it hasn't happened.  Can someone please 
tell me what I am doing wrong?
Here is the code: 

Range("A1").Select
Selection.Copy
Set wrdApp = CreateObject("Word.Application")
Set wrdDoc = wrdApp.Documents.Open("Mydoc.doc")
wrdApp.Visible = True
wrdApp.Selection.MoveDown Unit:=wdLine, Count:=2
wrdApp.Selection.MoveRight Unit:=wdCharacter, Count:=45Windows
wrdApp.Selection.PasteAndFormat (wdPasteDefault)
wrdApp.Selection.MoveUp Unit:=wdLine, Count:=9
Windows("Myexcel").Activate
Range("A4").Select
Selection.Copy
wrdApp.Selection.PasteExcelTable False, False, False

2.How to drag data in cells without dragging the formats

As I wrote in the subject box, how can I just drag the data without changing 
the borders and formats etc. in the original and destination cells? I know 
the hold down the control button trick, but for the people that don't even 
want to do that, is there a way to drag and drop the normal way?

3.Dragging selected data cells from Excel 2002 to Access 2002

I work in Office XP and need to copy selected values in a 
column of cells from an Excel 2002 spreadsheet and bring 
them into a certain column of an Access 2002 database.  
How do I do this? I tried to do CTRL and the mouse 
pointer and dragging but then ran into an error message.  
Help!  Is this do-able?

4.Excel - Trigger VBA Macro by Clicking on Standard Excel cell

First time poster

I would like to know if it is possible for the system to trigger the
execution of a VBA Macro with a simple click on an Excel Spread-sheet cell.



What I would like to accomplish is for the system to clear a series of
associated cells whenever I click on a cell to input a new value.



Any assistance would be greatly appreciated. A good on-line source for
tutorials of this nature would also be great.



Thanks in advance,



Craig


5.Need macro to drag values down to blank cells

Greetings all.  I have a spreadsheet that I use to upload data to a SQL 
Server using bulk insert.  Column 1 is for a town name, but it is only 
populated for the first row of every town.  For example, if there are 10 rows 
of data for Leesburg, only row 1 would have "Leesburg" in column 1, and rows 
2-10 will be blank for column 1, until you get to the next set of towns.  
Lets say the next 10 rows are for Tampa, starting at row 11.  Column 1 at row 
11 will say "Tampa", but rows 12-20 will be blank, until the next town 
starts.  What I do is drag each town down through the section for that town, 
so that every row has the town populated.  Is there a way to do this 
programatically?

Greg

6. Macro to create a Outlook Appointment from excel cell data

7. Excel Macro Rounds Value of Cell

8. EXCEL - I can not drag a cell with text to another cell,



Return to Microsoft OFFICE

 

Who is online

Users browsing this forum: No registered users and 55 guest