Adding New Lines To Current Code?

Dec 1, 2011

Code:
Sub Final()
Dim NameCell As Range
For Each NameCell In Sheets("! Names").Range("B1", Sheets("! Names").Cells(Rows.Count, "B").End(xlUp))

[Code]....

I want to pull data from ! Names. This code already Renames a new sheet from the ! Names sheet and also puts there name in cell C2 and phone number into cell C3 of the created sheet. I want to put more data from the ! Names sheet. How would i go about adjusting current code to do that?

View 4 Replies


ADVERTISEMENT

Adding Title Lines Within A Macro

Jul 20, 2007

i am completely new to writing macros. have recorded a macro but have just found out the each of the new sheets that the macro creates needs a line at the top of the sheet with a title in it

View 2 Replies View Related

Adding Lines And Conditional Formatting With Macros

Jul 4, 2008

I have only recently started playing around with macros, and am slowly getting into them. I do however still struggle a bit to ‘read’ them. Having played with formulas for years I can generally translate a string of formula text into English, like ‘if this cell value is greater than that cell value, then do this, if it is not then if it is equal to that cell value, do that, if not return 0’. Babbling like a child basically.

With visual basic I have managed to record some handy macros and then tweak them a little manually but I am still struggling to follow it going through it step by step reading it like a formula. So I hope you won’t mind me asking some very stupid questions. I mean well; I’m just a bit slow.

At present I am trying to do two different things on two different sheets, and I was wondering if perhaps one of you could nudge me in the right direction.

1:
I am trying to insert a blank row above every row that has a certain word in column B.

So basically ‘find value “Example” in column B, and when you find it, insert an entirely blank row directly above it’.

2:
Is a bit more challenging. I want to change the colour of a cell if the value in the cell corresponds with the value of another cell in the same column.

For example, I have a long list of surnames in column A. When I add ‘McNeil’ at the bottom, I would like to be able to run a macro that checks if the name McNeil appears anywhere else in column A, and if it does, that it changes the colour of the cell.

Preferably both of the cells that say McNeil, but one would do very nicely indeed.

If that is possible, I wonder if it is possible to do the same with the first name in column B, but only if there was a match for the surname in column A on the same row. So, if McNeil does not appear in column A, don’t bother, but if it does, does the corresponding first name appear in column B?

If both of that is possible, the next step would obviously be if McNeil appears in column A (say twice, once in A123 and once in A678), do cells B123 and B678 match as well?

View 14 Replies View Related

Adding Grid Lines And Line Numbers In The Report?

Mar 4, 2014

See the code below. It works fine but in the report that gets printed off, it doesn't display grid lines and line numbers .

[Code] .........

View 3 Replies View Related

Adding Reference Lines To Chart With Primary And Secondary Axis

Jan 10, 2014

I have a chart with sales data on one axis and inventory on a secondary axis. I have the average of each columns of data and want to add a reference line to each axis with it's average. I have added the averages to my data set, but it only adds the reference line to my primary axis. I actually began by manually inserting two lines to the chart (which seems asinine). They actually didn't print because they weren't actually on the chart, but rather just on the spreadsheet behind.

View 5 Replies View Related

Adding 10 Minutes To Current Time

May 11, 2009

In one of the spreadsheets there is a need to have a 'action at' field.

This is the next five minute time slot between 5 and 10 minutes in the future (eg 10.51 -> 11.00 , 1.56 ->2.05 etc)

View 14 Replies View Related

Select Series (lines) In Line Graph By Adding Userform With Checkboxes On A Chart

Apr 15, 2014

I want to add a user-form on a chart, which will have check-boxes that will allow me to select series(lines) that I want see and compare in a chart. Currently my line chart has 24 series (Lines) which makes the chart very difficult to view and looks very busy. How do I add list of check-boxes that will allow me to select one or multiple lines that I want to see at a time?

View 2 Replies View Related

Adding Current Date Column Using Excel VBA

Nov 8, 2013

How to add current date till the end of the column until data exists.

i used

With Range("A2")
.Value = Date
.NumberFormat = "mm/dd/yy"

A1 will have the heading and from A2 till data exists it should show the current date .i used above code it gives date in A2 but doesn't copy to the remaining rows.

View 5 Replies View Related

Current Month: Column B Equal To The Current Month Adding The Day In Column A

Sep 28, 2009

I have the following data:

column a: column B:
1
7
9
25

I need a formula to make column B equal to the current month adding the day in column A. so that column B equal the following:

column a: column B:
1 09/1/2009
7 09/7/2009
9 09/9/2009
25 09/25/2009

View 3 Replies View Related

VBA Code To Add Lines In Spreadsheet?

Jan 5, 2012

Have created a userform for people to use to populate a spreadsheet and based upon the values filled in cells, and date segregators, formulae determine whether the line of data is classified as new / increased or reduced.

Obviously I can sort this in excel quite easily by this criteria.

At the moment it is about 500 rows deep,and is sorted by N/I/R.....

What I ideally want to be able to do is create 3 new worksheets, N/I/R and then select all the N's and bung them in sheet N, row 2, and then repeat selecting all I and then all R, and pasting in respective sheets.........

Obviously it can be done, but I am far too rusty to do this.

At the moment, all is sorted in one worksheet, alpha ascending...

View 2 Replies View Related

Combining Two Lines Of Code

Jun 14, 2007

I have two lines of code which I want to consolidate into 1. for example

Sheets("Snapshot").Select
Range("A1").Select

I've tried combining but get errors.
can they be combined

View 3 Replies View Related

Skip Code Lines & Go To Another

Jul 13, 2007

My excel program on my home computer has a default number format so that when I type in a number such as "1", the spreadsheet displays 1E-20. If I enter the number as "1.0", the display will show correctly. I have tried changing the formats for the spreadsheet, but I still cannot get the program to work correctly. I tried reinstalling office, but nothing changed.

View 6 Replies View Related

Writing Long Lines Of Code

Aug 29, 2007

I've written a piece of code that is so long, I have to use the scroll bar to see the whole of it, which isn't very user friendly

if there's a way of splitting long lines of code over say 2 or 3 lines, so I can read the whole thing without having to use the scroll bar? I've noticed some people use _ at the end of the code and then continue writing on the next line, but when I do this, I get an error message saying

"Compile Error : Expected : line number or label or statement or end of statement"

View 9 Replies View Related

Find And Replace Vba Lines Of Code In All Worksheets?

Sep 11, 2012

I have spreadsheet application which have a ton of sheets and macro into it, and i work on devlop and program it , and add new feature and codes

i wana Module_Macro to find and replace lines of vba code and replace it with lines of codes .

i know ,i should use vbide and vbcompnent , but i dont know from where to start ?

View 9 Replies View Related

Place 1 Line Of VBA Code Into Mutiple Lines

Jun 11, 2009

I stumbled on this and wasn't sure why the code was placed on different lines and how the highlighted sections in red affect the basic round function.

ColorCompare = Round( _
(111111 + Blue + Red + Green) / (Green + LenPaint) _
, 0 _
)

View 3 Replies View Related

Adding Multiple Lines When "IF" Is True

Aug 25, 2008

Sometimes one employee may appear under more than one group (bartender, barback, waitstaff, etc.). I need to insert a formula that will check the other groups to see if this employee worked any hours in another group that week (I would assume a VLOOKUP would work), and then distribute the overtime hours accordingly.

If you view the attached worksheet, you can see I've entered a name and some hours. The formulas in cells M2 and N2 are my attempt to fix this problem. Anyway, the way the overtime hours are distributed is based on the group they worked under after they reached 40 hours. So looking at the example on the worksheet, Bob should have all of his overtime (13 hours) appear under O/T in row 2 because the 9 hours he worked on the waitstaff was before he was "officially" earning the overtime.

So I am needing the formula to check all of the groups other than it's own for a duplicate, add the total hours, and distribute the overtime accordingly.

View 14 Replies View Related

How To Convert Selected Multiple Lines Of VBA Code Into Comment Line

Jan 29, 2014

Adding ' in the beginning of a line converts the rest into comment line. I wonder if there is an easy way to convert a huge area into comment line to try something on code. I couldn't find such an option in the menu.

View 2 Replies View Related

Broken Line Chart Code Turning Lines Black

May 24, 2007

creating breaks in the line this script now simply turns the line black.

View 9 Replies View Related

Adding Code: Combine 2 Sections Of Code

Sep 9, 2009

I am now trying to combine 2 sections of code but being a complete VBA novice I'm stuck, where should the second Sub go so that it works,

View 4 Replies View Related

Using Loops On Current Code

Jul 27, 2006

I currently have the following macro - as you can see it is quite repetitive. I know it is possible to do this using a loop any ideas on how to do this would be appreciated.

Sub Clean()

Rows("4:4").Select
Selection.Delete Shift:=xlUp

Rows("5:5").Select
Selection.Delete Shift:=xlUp

Rows("6:6").Select
Selection.Delete Shift:=xlUp

Rows("7:7").Select
Selection.Delete Shift:=xlUp

I thought that this would work - but not so probably some basic syntax error:

Sub Runny()
For x = 4 To 17
Rows("x:x").Select
Selection.Delete Shift:=xlUp
Next x
End Sub

View 9 Replies View Related

How To Restrict Code To Current Workbook

Aug 3, 2014

I have the following code linked to a drop down list in my workbook.

[Code].....

It populates textboxes on the sheet with a lookup value result, the lookup value is taken from the dropdown box. The problem I have is any other excel workbooks that are open at the same time, the code is trying to run against those workbooks when I edit them, I can't seem to restrict the code to run only against the workbook in which the dropdown box which the code is linked to, exists in. I have tried moving the code to a module in the workbook but then the code does not seem to work as it does know which workbook the combo box and text boxes which should be filled with the lookuip result belong in

Link to workbook is [URL] .....

View 5 Replies View Related

Code To Identify Current Worksheet Name

Jan 22, 2013

What is the code to identify the current worksheet name? I want to store it in a variable so I can return to the worksheet later. I thought that the code was this:

myWorkSheetName = worksheet.name
:
:
Sheets(myWorkSheetName).Select

I receive a "Run-time error 424: Object required" message on the worksheet.name statement.

View 2 Replies View Related

VBA Code To Record Current Date

Apr 17, 2009

I know this is a simple question for all VBA droids...I guess the challenge is in how quickly I'll receive an answer. I hear the turn-around time on this board is pretty impressive. So here goes...

What is the VBA code for recording the current date without the date recalculating when the form is re-opened. I know the formula for automatic entry [=today()], but I need the date to stay the same. I can assign the date to any cell, so you may theorize any cell in the code. Remember...the trick is getting the date to stay the same once it's been automatically entered.

View 9 Replies View Related

Code To Keep Top 20 Rows Of Current Range

Oct 15, 2009

I need a macro that keeps only the top 25 rows in the current range and deletes the rest.

View 9 Replies View Related

VBA Code To Save As Name & Current Date

Feb 15, 2010

I want to schedule a print, for lets say every Sunday at midnight. I have managed to find some what of a solution by using the following vbscript and scheduling a print to default printer. Works perfectly if that is all I wanted.

Dim objExcel, objWorkbook, strFile
' Connect to Excel
Set objExcel = CreateObject("Excel.Application")
strFile = "C: est.xls"
' Open the Excel File for Printing
Set objWorkbook = objExcel.Workbooks.Open _
(strFile)
' Print to Default Printer
Set objSheet = objExcel. ActiveWorkbook.Worksheets(1)
objSheet.PrintOut
objExcel.ActiveWorkbook.Close
objExcel.Application.Quit

I do not want to print to an actual printer, therefore if I set my default printer as the document writer, the vbscript gets it as far as the "Save As" page. Is there a way I can add to this vbscript so it will save as well? Can I get it to save as "name"&[DATE], thereby having it save as a different name each time?
Can I change this vbscript to print to a named printer rather then a default printer? I am sure a PDF convertor may be of some assistance with this, but I do not have an PDF converter on my computer, and as this will be carried out on a computer that I will not have administration rights, I can not download one.

View 2 Replies View Related

Utilize Current Year Within Excel Code?

Dec 27, 2012

I've been heavily updating my Budget file I've written in excel. The code I'm working with and having slight trouble with is as follows

Try this formula. Column letter & Row number are for example only. Array formulas will have curly brackets {} emcompassing the ENTIRE formula. You do not add these, you Enter the formula with Ctrl+Shift+Enter and Excel will add them (details: Array formulas). Many more Excel Formulas
 Z100 =IF(TODAY()>DATE(2013,1,31),"January's Ending Balance is:",IF(TODAY()<=DATE(2013,1,31),"January's Current Balance is:")) 

Basically, if the current date is after the last day of a given month (in this case January 31), then the cell should display "January's Ending Balance is:", if between January 1, (current year), and January 31, (current year), it should display "January's Current Balance is:". The code above does work great, but I need it to look at the current year according to the computer's date, and go by that, instead of having to change the code where it says 2013 to 2014 etc every year. This would be a hassle, as I have a tab coded for each month of the year. Id rather it be automated.

View 8 Replies View Related

Code To: Open Another Workbook And Close Current

Jul 31, 2007

I want code to:
Open EstimatingSheet.xls
SaveAs current workbook as Range B13 &".xls"
Open EstimatingSheet.xls workbook from somewhere on C:
Then close the one with B13.xls

View 9 Replies View Related

Fill Columns Botom Up Fashion (editing Current Code)

Sep 8, 2008

I have a piece of code that prompts me to choose which column to be filled bottom up, I would like to modify this and add it in as a macro so that it fills columns H and columns I in a bottom-up fashion

View 13 Replies View Related

VBA Code To Set Unknown Range Based On Current Date In 1 Column

Jul 21, 2009

i have a sheet for monitoring sickness. i have used a macro before which automatically selects a range and emails it to recipients when i press a button. what i would like to do is have excel automatically choose the range for me based on today's day. in the attached example i would like column "A" copied along with the 5 columns before today's date, today's date column and also the 5 columns after today's date. paste the lot into an email and send. (i have highlghted the parts i would like copied and pasted into an email based on today's date (21st july).

View 4 Replies View Related

Display Current Code Line Number While Macro Running

Sep 19, 2007

Is it possible to display both the current code line number and the total line count of a macro while it's running?

I was thinking it would be handy for a progress indicator if the ProgressBar max value could be set to the LineCount total of the procedure and each line of code would increment the progressbar as the macro ran.

View 9 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved