excel-vba

Assign filename to pdf from cell value

南笙酒味 提交于 2020-02-08 02:55:06
问题 I have a macro that saves the excel file into a PDF one: Sub PDF() ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _ Filename:="C:\Report.pdf", _ OpenAfterPublish:=False End Sub How do I assign the pdf name to a value in a specific cell in excel? And how I do specify the save directory as the same where the excel file is located? 回答1: If you modify your code like below, your ActiveSheet will get exported as a .PDF to the same folder as the ActiveWorkbook , and with the name defined in cell

Multiple Word Doc to pdf convert

心不动则不痛 提交于 2020-02-08 02:12:09
问题 I was working with a vba code that will convert multiple word docs in a folder to individual pdf files. The problem is that I am not able to save the word file as pdf. Below is the code: Sub convertword() Dim Filename As String Dim irow As Integer Dim jsObj As Object Dim NewFileName As String Dim objWord As Object Dim strDocName As String, strDocName1 As String, strDocName2 As String Dim strMyPath As String irow = 4 Do While Cells(irow, 2) <> Empty Filename = Cells(irow, 2).Value NewFileName

EXCEL VBA Paste from array, change paste order

浪子不回头ぞ 提交于 2020-02-07 09:08:05
问题 I'm wondering if there is a way that I can choose in wich order my columns will end up in when I run this code. I want the columns to end up in that order they are copied, but they paste in the order they are from the other sheet. I have managed to swap the columns after they are pasted, but it requires so much code and the macro is slow as it is. SearchString = "start" Set aCell = phaseRange.Find(What:=SearchString, LookIn:=xlValues, _ LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:

Excel VBA remove blank row after cut

安稳与你 提交于 2020-02-07 06:03:25
问题 I have this code which cuts and pastes an entire row to another sheet, how could I remove the blank row which now appears on the first sheet in which the original row was cut. Set ASR = ActiveWorkbook.Sheets("Main") Set LS = ActiveWorkbook.Sheets("Exclusions") ASR.cells(i, "C").EntireRow.Cut Destination:=LS.Range("A" & LS.Rows.Count).End(xlUp).Offset(1) I was hoping this line of code which I got from this answer would remove the blank rows, but it did not work ASR.cells.Delete Shift:=xlUp 回答1

Excel VBA remove blank row after cut

点点圈 提交于 2020-02-07 06:02:04
问题 I have this code which cuts and pastes an entire row to another sheet, how could I remove the blank row which now appears on the first sheet in which the original row was cut. Set ASR = ActiveWorkbook.Sheets("Main") Set LS = ActiveWorkbook.Sheets("Exclusions") ASR.cells(i, "C").EntireRow.Cut Destination:=LS.Range("A" & LS.Rows.Count).End(xlUp).Offset(1) I was hoping this line of code which I got from this answer would remove the blank rows, but it did not work ASR.cells.Delete Shift:=xlUp 回答1

Retrieve items in collection (Excel, VBA)

﹥>﹥吖頭↗ 提交于 2020-02-06 07:50:52
问题 I'm getting a Type Mismatch-error, when trying to retrieve items from my collection. What I mainly want to do, is to collect all customers within as collection, and past all results on my ListBox for visualization. The reason why I'm using a class-module is due to the fact, that UDT are pasting an error: "Only user-defined types defined in public object modules can be coerced to or from a variant or passed to late-bound functions". So I started programming all properties in classes instead,

Retrieve items in collection (Excel, VBA)

ぐ巨炮叔叔 提交于 2020-02-06 07:50:06
问题 I'm getting a Type Mismatch-error, when trying to retrieve items from my collection. What I mainly want to do, is to collect all customers within as collection, and past all results on my ListBox for visualization. The reason why I'm using a class-module is due to the fact, that UDT are pasting an error: "Only user-defined types defined in public object modules can be coerced to or from a variant or passed to late-bound functions". So I started programming all properties in classes instead,

Copy/Paste remove duplicates/blanks: Array Column

半城伤御伤魂 提交于 2020-02-06 07:41:38
问题 This issue is related with VBA. Involves copy and paste data (unique values, formatting and exclude blanks). What I have: 1 sheet (DB) with different headers, and then I've the data below (can be numbers or strings or blanks). What I want: Have in another sheet (Destination) with the unique values of some columns from the data source but without data formatting and without blanks. My idea: Copy the specific columns I want in DB sheet and paste into Destination sheet (specific columns as well)

Copy/Paste remove duplicates/blanks: Array Column

陌路散爱 提交于 2020-02-06 07:40:07
问题 This issue is related with VBA. Involves copy and paste data (unique values, formatting and exclude blanks). What I have: 1 sheet (DB) with different headers, and then I've the data below (can be numbers or strings or blanks). What I want: Have in another sheet (Destination) with the unique values of some columns from the data source but without data formatting and without blanks. My idea: Copy the specific columns I want in DB sheet and paste into Destination sheet (specific columns as well)

Creating a macro to compare cell values in the same worksheet but different columns

假如想象 提交于 2020-02-06 03:55:27
问题 I am trying to do up a macro that will compare the cell value in a systematic manner. I have 2 data sets. The macro that I intend to create basically will compare the value from "C3:M25" with the values from "O3:Y25". My macro should starting comparing the values in range("C3") with range ("O3"). If the C3.value > O3.value, it will change the interior.colourindex.value and the font colour Once it is done with the first comparison, it will move down to the next row i.e Compare range("C4")