excel-2007

Need to find a way to loop this macro through every other column

蓝咒 提交于 2019-12-11 13:45:48
问题 I have written a macro that to return specific values in one cell based on a vlookup of the concatenated values of two other cells. This macro may need to run in every other column for 30 columns. Is there a way that I can loop this, so that I don't have to type out 30 variations? Here is the section of code that I am referencing: Cells.Select ActiveWorkbook.Worksheets("Vendor Request").Sort.SortFields.Clear ActiveWorkbook.Worksheets("Vendor Request").Sort.SortFields.Add Key:=Range( _ "F2:F"

Find a string in web query without putting webpage contents on the sheet

a 夏天 提交于 2019-12-11 12:24:18
问题 I have a webquery within a macro. .Refresh BackgroundQuery:=False The above line puts the webpage contents in the active worksheet. Then I find a string "approved" with the code given below Set findRng = Cells.Find(What:="approved", After:=ActiveCell, _ LookIn:=xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, _ SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False) If the string is found, I do some job with the code given below If Not findRng Is Nothing Then 'do some job End If Can

Extracting the two smallest values corresponding to the unique-to-the-column ID

馋奶兔 提交于 2019-12-11 11:46:06
问题 I have two rows, that is: ID and Time . I want to extract the two smallest Time value corresponding to the unique column ID. ID Time 27604 13:00:12 27604 13:00:32 27604 13:00:34 27604 13:00:38 27604 13:00:41 27604 13:00:47 27604 13:00:50 27605 13:00:20 27605 13:00:23 27605 13:00:39 27605 13:00:42 27605 13:00:45 27605 13:00:48 27605 13:00:54 27605 13:00:57 27605 13:01:00 27606 13:00:49 27606 13:00:52 27606 13:00:55 27606 13:01:01 27606 13:01:04 27606 13:01:07 For ID 27604 I want to extract 13

Closing Excel file after reading

浪子不回头ぞ 提交于 2019-12-11 10:53:02
问题 Here is my code for opening the Excel file and reading the data, everything is working fine but what I would like is to close once the Excel file is read, how would i do that? I try Dispose the object but did not help. public static DataTable ExcelWorkbook(string workbookName) { string connectionString = String.Format(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties=""Excel 8.0;HDR=YES;IMEX=1;""", FILENAME); string query = String.Format("select * from [{0}$]",

Format Excel Chart Background using C#

混江龙づ霸主 提交于 2019-12-11 10:16:40
问题 I can already populate the data into the spreadsheet, create the chart based on the range I select. However, when it comes to formatting the actual chart I feel a bit lost as their are so many options!! It is an xlCylinderBarStacked type chart. I simply need to make the color of the bars a nice light orange and make the background a light blue fading into white at the bottom. Any idea's how to do this? 回答1: Just to close this question off. I played around a little with the properties and the

How can i use Persian date (Shamsi) in excel 2007?

淺唱寂寞╮ 提交于 2019-12-11 10:04:42
问题 I,d like to use Persian date (Hijri- Shamsi) in excel 2007 worksheet directly as the base of calculation.but dont know how? 回答1: I would convert the Persian dates to Julian dates via VBA , perform the calculations with standard Excel functions and then convert them back to Persian with VBA I posted a reference here 来源: https://stackoverflow.com/questions/22880225/how-can-i-use-persian-date-shamsi-in-excel-2007

Excel prompt user for number to use in macro

荒凉一梦 提交于 2019-12-11 09:13:46
问题 I have a recorded macro to pull select fields from a web service, the URL is something like http://xxxx.com/reportviewer.aspx?ids= 123456789012 I would like to prompt the user to input that number as a variable and have the number be passed to the 2 locations were that number is used in the macro. I know that i have to create another macro to have the user input a value for after that I'm unsure of how pass that along to be filled in the correct location? Here is my code so far Sub Macro2() '

Workbook_Open() is not executed with excel already running

雨燕双飞 提交于 2019-12-11 08:38:48
问题 using excel 2007 I programmed a macro, which I would like to start with the Workbook_Open() call (placed in "thisWorkbook"). This works fine as long as this is a new "excel-session", therefore it is started together with the xlsm-file / I start excel and load the file. However as soon as excel is already running, the Workbook_Open() function is not executed. The macro otherwise still works fine, as soon as I start it manually after the workbook has been loaded. To clarify: This happens even

excel dim cell text value as controls

泄露秘密 提交于 2019-12-11 08:16:39
问题 I am having trouble with my macro. I have a button and a few check boxes on a form, i am trying to write a code that when i click the button it will check the range("A1").text, after take that text (which in this case is "checkbox1") and i want to say something like this: questionnaire = Range("A1").Text questionnaire.Value = Range("A2").Value since i have many checkboxes as mentioned earlier, i want that when i write a certain controls name in "A1", when i click the button, that control will

How to import Excel related BOM-list content into a excel sheet in Excel-VBA?

自作多情 提交于 2019-12-11 07:56:01
问题 How to implement a spreadsheet to do something more dynamic and recyclable for more user to use? By allowing the user to browse and import 2 excel related BOM-list files from the computer local drive into sheet 2/3 before i run the above code to find the differences? Eg: Something like having two CommandButton's which can import all the excel BOM-list data information into sheet 2/3 without making any changes to the original? Before running any comparison test and a reset button for removeing