vba

Copy the element throughout the whole workbook with exclusion some sheets

眉间皱痕 提交于 2021-02-11 14:15:06
问题 I would like to copy the element throughout the whole workbook, keeping one sheet excluded (the very 1st one). Following the query here: Copy the element throughout a whole workbook and the advice here: VBA - Loop Through All Sheets And Exclude One I prepared the code as per below: Sub asbuiltcopy() Dim Ws As Worksheet, ws1 As Worksheet, ws2 As Worksheet, s As Shape Set ws1 = Worksheets("Frontsheet") 'sheet containing original textbox Set ws2 = Worksheets("Readme") Set s = ws1.Shapes(

VBA - WORD Deleting rows after and before specific word

限于喜欢 提交于 2021-02-11 14:15:06
问题 I'm trying to clean up my Word document using VBA. What i need to do is to find a specific word (usually a website) then select the line it is in and then select and then remove text line above(only 1 line), the lines under that website line as well (sometimes more than 2 - if the text is longer). I'll try to show you how the line looks now. Something happend at someplace! website.com 08.01.2019 Something happend at someplace and it was a bad person doing it. He used spaces instead of tabs in

vba code for changing query xls source prompt

a 夏天 提交于 2021-02-11 14:13:39
问题 I was searching for a simple vba code that open the prompt for change source for query that is xls sheet. I have a lot of query steps that i need to do every time that source is changing. So basically i would like to have macro that does this manual steps for a certain query name (i have a number of them in a workbook): in the query edit mode, click the source change button:source macro should open the prompt so that i can manually pick the xls file:screen also, the data can be in a sheet

Search a range of word from a paragraph

帅比萌擦擦* 提交于 2021-02-11 14:01:32
问题 I have a list of word. i want to mark that word within a paragraph if match. if word match then want to change the color. I am trying this code: Sub HighlightStrings() Application.ScreenUpdating = False Dim rng As Range Dim InputRang As Range Dim cFnd As String Dim xTmp As String Dim x As Long Dim celValue As String Dim m As Long Dim y As Long Dim xFNum As Integer Dim xArrFnd As Variant Dim xStr As String celValue = Range("A1").Value cFnd = celValue If Len(cFnd) < 1 Then Exit Sub xArrFnd =

Input 12:00 PM on VBA Userform Combobox

与世无争的帅哥 提交于 2021-02-11 13:53:59
问题 I have this vba userform combobox that shows time range. In the rowsource, i have inputted 12:00 PM. But everytime i click 12:00 PM in the combobox, it shows 12:05 AM instead. Any idea how to solve this problem? 回答1: Use click event instead of change event Private Sub ComboBox5_Click() Dim t As Double With ComboBox5 t = Val(.List(.ListIndex)) .Value = Format(t, "hh:mm:ss AM/PM") End With End Sub 回答2: A ComboBox handles text strings. Excel records time as a fraction of 1. 12:00 PM = 0.5 (half

Duplicate as Value only last row into adjacent column Excel

无人久伴 提交于 2021-02-11 13:50:30
问题 I'm creating a VBA application with some forms. When the data is inserted into the Table, Column A calculates a value with a formula. After that I need to copy the resulting value (like paste special, values only) into the adjacent Row I just need to know how to select the last row everytime. I have tried with ActiveCell , Find , Range etc. but none are working Selection.Copy ActiveCell.Offset(0, 1).Select Selection.PasteSpecial Paste:=xlPasteValues 回答1: Try this: Selection.Copy ActiveSheet

what is wrong with this line of vba code for Excel Print

人走茶凉 提交于 2021-02-11 13:49:32
问题 I have a combobox with list of page size in excel. i want to change page sizes with combobox selection change. Following is not working Public Sub UpdateSize() Dim Papersizetext As String Papersizetext = "xlPaper" & Worksheets("Static").Range("B7").value 'A4 is the value in cell B7 shgenerate.PageSetup.PaperSize = Papersizetext 'not working shgenerate.PageSetup.PaperSize = "xlPaper" & Combobox1.value 'this also not working shgenerate.PageSetup.PaperSize = xlPaperA4 'is working - i want above

Automatically Set Chart Series Colors to Match Source Cell Colors by Category not Series

女生的网名这么多〃 提交于 2021-02-11 13:49:23
问题 I have a VBA code to automatically change the color in a chart, which I found from this site: http://datapigtechnologies.com/blog/index.php/automatically-set-chart-series-colors-to-match-source-cell-colors/ The code is posted below. My problem is that I need this code to apply to the chart's horizontal categories instead of the series because I am using a horizontal bar chart and the data has to be arranged in this way. How can I change the VBA to apply the automatic color change to the

How to concatenate more than one column at the same time in excel using VBA

五迷三道 提交于 2021-02-11 13:48:57
问题 I know how to concatenate when we're dealing with only one column. Example : Number Color 1 blue 1 red 1 pink 2 yelow 2 blue 3 red result : Number Color 1 blue, red, pink 2 Yellow, blue 3 red This is the code i'm using and it works : Sub ConcatenateCellsIfSameValues() Dim xCol As New Collection Dim xSrc As Variant Dim xRes() As Variant Dim I As Long Dim J As Long Dim xRg As Range xSrc = Range("A1", Cells(Rows.Count, "A").End(xlUp)).Resize(, 2) Set xRg = Range("D1") On Error Resume Next For I

VBA Excel replace Word text with Excel cell value

时间秒杀一切 提交于 2021-02-11 13:48:25
问题 Good morning, I would like to replace the address in Word using the one, placed in the Excel cell. My situation looks like in the image below: I have got an address in Excel and I want to paste in in the Word bracket, based inside the table cell. There are some solutions: Write to Word Document from Excel VBA Pasting a String from excel to Word using word-VBA VBA from Word to Excel VBA macros: Excel to Word text replacement which differs from my situation. My code so far looks like this: Sub