September 10, 2016, 6:33 pm
Hi,
I am using this code to add a autotext to a word document, but I'm having trouble to add another autotext. I have an autotext for the upper section, body, and lower section of the word document.
I can add the upper, but using the same code will replace the existing autotext to the new autotext. How to insert multiple times?
Code:
Dim objWord As Word.Application
Dim docWord As Word.Document
Dim WordHeaderFooter As HeaderFooter
Set objWord = CreateObject("Word.Application")
objWord.Visible = True
Set docWord = objWord.Documents.Open("C:\Users\ii88\Desktop\autotext\ENG_TEMPLATE.dot")
docWord.AttachedTemplate.AutoTextEntries("INTRO").Insert Where:=docWord.Range, RichText:=True
docWord.AttachedTemplate.AutoTextEntries("BODY").Insert Where:=docWord.Range, RichText:=True
docWord.Activate
Thanks
↧
September 10, 2016, 6:42 pm
Hi, is there a macro when I run it , it will pop up a windows "Please input Cover= XXXXX", XXXXX need to be filled by user and XXXXX will fill F10, thxyou!
ef cover.jpg
↧
↧
September 10, 2016, 8:50 pm
Hi,
For some reason I am unable to attach my file...perhaps I can try again to whomever replies to this...?
I want to be able to send an automatic email say every Sunday night at 1am so it is there for an employee on Monday to review.
I want the email to show which employees have expired tickets and which employees have tickets expiring in 30 days. I have set the cells to reflect that expired dates are in red and those expiring in 30 days are in green.
The email can be basic such as;
The following employees have tickets expiring within 30 days:
Employee first name, Employee last name
Employee first name, Employee last name
etc
The following employees have expired tickets on file;
Employee first name, Employee last name
Employee first name, Employee last name
etc
There are multiple columns for every employee but I am happy with something that acknowledges that if there is one or more red or green cells that that employees name can be included on the list that gets emailed.
Thank you for your help!
Becky
↧
September 11, 2016, 12:41 am
Hey Guys
I have the attached sheet as an example and what I am trying to do is, if the category = 'Regular' and as soon as the progress is selected at 100% (meaning the task is complete), I want columns A:D to be copied and pasted to the next available row, with column F indicated as todays date (to prompt the user to amend this to the next one).
E.g. if Reference3 task- you change progress from null to 100%, immediately that row is copied and pasted to row 5, with a date due of today and blank progress.
Cheers
↧
September 11, 2016, 2:14 am
Hello all,
The following code lets me write changes on the INTERFACE sheet to the DBS sheet.
I also managed to copy comments to the DBS-sheet.
However the copying of comments only works if the cell value is changed, this is because of the Worksheet_Change event.
Is it possible to detect if the comment itself is changed (edited or deleted)?
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim KeyCells As Range
Set KeyCells = Range("F9:S524")
If Not Application.Intersect(KeyCells, Range(Target.Address)) Is Nothing Then
Application.EnableEvents = False
R = Target.Row
C = Target.Column
Dim firstDate As Date, secondDate As Date, n As Integer
firstDate = DateValue(Sheets("MISC").Range("B3").Value)
secondDate = DateValue(Cells(6, C).Value)
n = DateDiff("d", firstDate, secondDate)
Sheets("DBS").Cells(R - 7, n + 7) = Target.Value
On Error Resume Next
Sheets("DBS").Cells(R - 7, n + 7).AddComment Target.Comment.Text
Application.EnableEvents = True
End If
↧
↧
September 11, 2016, 2:31 am
Hi, my first post and only new to VBA so if I'm in the wrong area or haven't supplied enough info I apologise !!
I want to have a button set up so users can click it - a inputbox opens up "Enter New Sheet Name" then once you type that in it copies the two template sheets I have set up and pastes them to the end of the workbook with the entered name followed by "_Form" and "Chart"
This is what I currently have -
Sub New_Prism()
Dim sName As String
Dim wks_form As Worksheet
Dim wks_chart As Worksheet
Set wks_form = Worksheets("Form_Template")
wks_form.Copy After:=Sheets(Sheets.Count)
Set wks_form = ActiveSheet
Do While sName <> wks.Name
sName = Application.InputBox _
(Prompt:="Enter new worksheet name")
On Error Resume Next
wks.Name = sName & "_Form"
On Error GoTo 0
Loop
Set wks = Nothing
End Sub
It creates the one sheet I have in the macro but then gets stuck in a loop...?
Any help would be really appreciated!!
Thank you in advance
↧
September 12, 2016, 12:16 am
Hi All,
i'm trying to use a statistical plugin designed by the university i'm studying at, but i'm getting an error message :De code in dit project moet worden bijgewerkt voor gebruik op 64-bits systemen. Controleer Declare-instructies en werk ze bij. Markeer ze vervolgens met het kenmerk PtrSafe. which translated to English means something like: The code in this project must be updated for use on 64 -bit systems. Check Declare statements and update them then mark them with PtrSafe.
is this something which can be done by myself, or do i need to contact the university (which probably will take for ever) to update the file/code?
thank u in advanced for your answers/help.
i've attached the file.
cheers,
Sam
↧
September 12, 2016, 12:31 am
Hi All,
Need your help!
I want to copy every next 5 rows from column A from sheet1 and transpose in sheet2 using vba.
Please find the attached sample file.
Regards,
Xlhelp7
↧
September 12, 2016, 12:56 am
Can the Form Checkbox text be dependent on the value of a cell, either by =Cell or VBA? I've searched the web and can't find anything on it so I'm assuming 'no'.
↧
↧
September 12, 2016, 2:07 am
Hi again,
I've got a "Clients" sheet, where I have client data. Sometimes I just need to printout the phone numbers, or just the addresses etc.
So I made this user form where I have check boxes to choose.
For example :
If the check box 1 is selected, the range to print will be : Range("A8:A100")
If the check box 2 is selected, the range to print will be : Range("K8:K100")
if the check box 1 is selected with check box 2 , then ranges will be Range("A8:A100, K8:K100)
and so on
I wrote this so far :
Code:
Dim mySheet As Worksheet
Set mySheet = ThisWorkbook.Worksheets("Clients")
Dim myRange1,myRange2, myRange3, myRange4, myRange5, myRange6, myRange7, myRange8, myRange9 As Range
Dim myMultipleRange As Range
Set myRange1 = mySheet.Range("B8:B" & myLastRow) 'Client No
Set myRange2 = mySheet.Range("C8:C" & myLastRow) 'Name
Set myRange3 = mySheet.Range("E8:F" & myLastRow) 'Telephones
Set myRange4 = mySheet.Range("I8:I" & myLastRow) 'Kid2 Names
Set myRange5 = mySheet.Range("T8:T" & myLastRow) 'Kid1 Name
Set myRange6 = mySheet.Range("T8:T" & myLastRow) 'Kid1 BDate
Set myRange7 = mySheet.Range("T8:T" & myLastRow) 'Kid2 BDate
Set myRange8 = mySheet.Range("T8:T" & myLastRow) 'Kid1Services
Set myRange9 = mySheet.Range("T8:T" & myLastRow) 'Kid2Services
Set myMultipleRange = Union(myRange1, myRange2)
myMultipleRange.Select
But I can not figure out how to deal with the IF conditions.
If checkbox1.value = true then..... what ?
thank you in advance!
↧
September 12, 2016, 2:10 am
Hi all, I have created a few "Public Functions" that are stored in a master control file ( a file whose name changes with each new version). These functions need to reference named ranges in various files, and I do not wish to "hard code" these file names into the function nor do I want to have too many arguments when entering the function on the spread sheet. How can I get the function code to automatically look up the required file name irrespective to which workbook is "active" at the time of recalculation?
in the code below the file name is hardcoded in "MastFile" this works very well but I would like to remove the hardcoded statement so as to make the code more portable between different files.
Please help.
Code:
Public Function VehChoice(RouteType As String, MaxVol_1 As Double, Maxvol_2 As Double)
'Calculates the type of vehicle required based on route type and the expected Max Vol on the route
Dim Vol As Double
Dim Choice As String
Dim Trunk6m As Double
Dim Trunk9m As Double
Dim Trunk12m As Double
Dim Feeder6m As Double
Dim Feeder9m As Double
Dim Feeder12m As Double
Dim MastFile As String
'Set MastFile name
MastFile = "Costing_model_BP_2032_V1_2.xlsm" ' Worksheets("Parameters").Range("Mast_File").Value ' sets the name of the Master file.
'Set the bus type values from the assumptions sheet
Trunk6m = Workbooks(MastFile).Worksheets("Assumptions & Rates").Range("Choice_6m").Value
Trunk9m = Workbooks(MastFile).Worksheets("Assumptions & Rates").Range("Choice_9LERH").Value
Trunk12m = Workbooks(MastFile).Worksheets("Assumptions & Rates").Range("Choice_12LERH").Value
Feeder6m = Workbooks(MastFile).Worksheets("Assumptions & Rates").Range("ChoiceF_6m").Value
Feeder9m = Workbooks(MastFile).Worksheets("Assumptions & Rates").Range("ChoiceF_9m").Value
Feeder12m = Workbooks(MastFile).Worksheets("Assumptions & Rates").Range("ChoiceF_12m").Value
'Determine the maximum MaxVol value
Vol = WorksheetFunction.Max(MaxVol_1, Maxvol_2)
'Determine if route is Feeder or Trunk
Select Case RouteType
Case Is = "BRT - full dedicated lanes":
Select Case Vol
Case Is <= Trunk6m: Choice = "6m"
Case Is <= Trunk9m: Choice = "9LERH"
Case Is <= Trunk12m: Choice = "12LERH"
Case Is > Trunk12m: Choice = "18LERH"
End Select
Case Is = "Feeder routes":
Select Case Vol
Case Is <= Feeder6m: Choice = "6m"
Case Is <= Feeder9m: Choice = "9LERH"
Case Is <= Feeder12m: Choice = "12LERH"
Case Is > Feeder12m: Choice = "12LERH"
End Select
End Select
VehChoice = Choice
End Function
↧
September 12, 2016, 2:10 am
Hi there,
I really don't know how to explain this.
Basically, I want a UserForm to select an item from a drop down menu, this will then search a table and return the values from other columns that match the drop down menu.
It's only two drop down menu's to search, first we'd select an option from the "Location" list, followed by selecting an option from the "Floor" list. I want this to match the location column and floor column of a table and then return the information in the following columns (i.e. anchor point, contact name etc.). Of course, when there is nothing selected, I want it all to remain blank.
I've attached a very basic excel file to show what I want to appear.
I hope someone is able to understand it, I know what I want in my head, not very good at trying to explain it.
Thank you.
↧
September 12, 2016, 2:13 am
Hello,
I have this code to send email from excel sheet:
Code:
Private Sub CommandButton1_Click()
sendemail
End Sub
Public Function sendemail()
On Error GoTo ende
esubject = Range("e3").Value
sendto = "avicoifman@gmail.com"
ccto = ""
ebody = Range("e4").Value
Set app = CreateObject("Outlook.Application")
Set itm = app.createitem(0)
With itm
.Subject = esubject
.to = sendto
.cc = ccto
.Body = ebody
.display
.send
End With
Set app = Nothing
Set itm = Nothing
ende:
End Function
i want to upgrade it and add a pop up msg after the email was sent
and after ok is pressed the content will be erased from the fields (e3 and e4)
can someone help me to add these features?
thanks in advance.
Avi
↧
↧
September 12, 2016, 2:58 am
Hi,
I have this report which is I need to have condition in other workbook and make a vlookup in the master workbook.
when trying to do the if function it goes to the active master workbook and when i try activating the other workbook i recieved errors to
also i need to find the Last year and last 90 days on my pivot table.
attached is my data or below is my code, need your assistance editing my code.
.
Code:
Sub test2()
'Y:\MNLGSCFNA\OTC\OTC New\Team Files\Other Tasks & Reporting\Reports\REPORTS\GRC\CY\CREDIT CUSTOMER PERFORMANCE REPORT\2016\0830
Dim rw As Long, x As Range, rf1 As Range
Dim extwbk As Workbook, twb As Workbook
Application.ScreenUpdating = False
Set twb = ThisWorkbook
'''''''''''''''''''''''''''''''''''''''''''''''''''
spath = "Y:\MNLGSCFNA\OTC\OTC New\Team Files\Other Tasks & Reporting\Reports\REPORTS\GRC\CY\CREDIT CUSTOMER PERFORMANCE REPORT\2016\" & Range("B3") & "\"
fname = Range("b3") & "_rdd1101.xlsb"
Set extwbk4 = Workbooks.Open(spath & fname)
Set x4 = extwbk4.Worksheets("Sheet1").Range("A:E")
' Set rf = Range("A4:A6").Find("LAST YR")
'Set rf1 = Range("E:E").Find("last 90 days")
'Set rFound = Range("E:E").Find("wat")
'For i = 1 To 10
'Set rFound = ActiveSheet.Range("A:E").Find("last 90 days")
' If x4.Cells(i, 3) = rFound Then
' End If
' MsgBox i
'Next
For Each PT In ActiveSheet.PivotTables
y = PT.Name
Next
ActiveSheet.PivotTables(y).PivotFields("Company Code").CurrentPage _
= "(All)"
With ActiveSheet.PivotTables(y).PivotFields("Company Code")
.PivotItems("1000").Visible = True
.PivotItems("7000").Visible = True
If acs = 1000 Then
.PivotItems("7000").Visible = False
Else:
.PivotItems("1000").Visible = False
End If
End With
With twb.Sheets(acs)
For rw = 4 To .Cells(Rows.Count, 2).End(xlUp).Row
.Cells(rw, 19) = Application.IfError(Application.VLookup(Cells(rw, 2), x4, 2, False), 0)
Next rw
End With
extwbk4.Close savechanges:=False
Application.ScreenUpdating = True
End Sub
[attach]data.xlsm[/attach]
I need to have data in the other book in the Last yr and last 90 days in my master file to find it in other workbook
thanks.
↧
September 12, 2016, 2:58 am
Hi, I have some VBA code that will search some cells and activate an e-mail when I click a command button.
However, I would like to develop this further to notify other indivividuals if a cell (O8) has the word "yes" but do nothing if its unpopulated.
Can anyone help?
I have had to include code as a note book attachment as the firewall will not allow me to display the code, apologies for breach of forum rules.
Thanks
↧
September 12, 2016, 3:09 am
Hi chaps... just a quick one that's annoying me...
I've created a little Private sub which will clear specific contents from a row, when a "No" is selected from the drop down menu in the first column, however I don't know how to apply this to successive rows... in other words, the first row of my spreadsheet will clear when I select "No", but I don't know how to alter the code to make this happen on every row, does the sub need to incorporate an array to of somekind...? how do I set it up so if say row 12 yes/no box says no, only row 12 will clear..?
I have attached my spreadsheet, any help would be... really helpful (?!?!)
↧
September 12, 2016, 3:10 am
Hi All
I have had no results with the following code. I have searched for hours and still can't come up with helpful input.
The below code is supposed to take the TRow rows to Hist table and if I change the Trow value, it must then take that rows to Hist table and so on etc....It is driving me nuts...Please assist. i have added my workbook.
Code:
Sub Move()
Dim TRow As String, LastRow As Long
TRow = Sheets("Temp").Range("C11")
LastRow = Sheets("Hist").Range("a" & Rows.Count).End(xlUp).Row
With Sheets("Temp")
With .Range("A1").CurrentRegion
.AutoFilter 2, TRow
.Offset(1).Copy Sheets("Hist").Range("A" & LastRow)
.Offset(1).EntireRow.Delete xlShiftUp
End With
ActiveSheet.ListObjects("Table2").Range.AutoFilter Field:=2
End With
Application.ScreenUpdating = True
End Sub
↧
↧
September 12, 2016, 3:25 am
Every month I report to my clients where they appear in Google for particular search phrases. Every search term has a row. Every month I report their current rankings for each term in a column. In between the columns for each month there is a column showing the 'change' (i.e. movement up or down in Google).
I've uploaded an attachment to show the format.
I want to make it so that I can easily choose any row (i.e. a particular search phrase) and show a chart plotting only the numbers from each month (not the change) so I need to plot every other column, for example B3, D3, F3, H3 and so on.
FYI: I don't know if this is important but... if a search phrase doesn't appear in the top 100 results in Google, I will input "101+" for that month. I presume I'll need to do something extra so that can be plotted?
Can anyone help me? Each client has over a hundred search phrases and many have over two years worth of data. It would be extremely time consuming to have to do this manually!
↧
September 12, 2016, 4:17 am
I'm new to this site and just discovering the magical world of VBA and Macros.
Just a brief summary: I work for a company that often does inspections on buildings. Some of the reports we do, we must include the same data sorted in several different ways. I have to list every Room and each material and the quantity of it for every room. Then further in the report, i have to list the materials and what rooms they are in. For many of these buildings there are 50+ rooms and 50+ different materials. The materials and quantities vary from room to room, so we use a master table with all of the materials and rooms pre listed so as we walk through, we can mark off quantities if they are in the rooms.
I attached a small example of what our typical spreadsheets look like and the products we need for our final reports. Hope i'm looking in the right place. If not please direct me to where to look.
Thanks!
↧
September 12, 2016, 5:01 am
Hi,
I'm trying to fill a cell with information but i'm getting the "block if error". any help would be gratefully received.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Range("O9").Value = YES Then
Range("X9").Value = "lfhffh@hotmail.com"
If Range("O9").Value = NO Then
Range("X9").Value = ""
Else
Range("X9").ClearContents
End If
Application.EnableEvents = True
End Sub
↧