excel-vba

Copy Cell and Move to Another Cell (Offset) - VBA BEGINNER

北城余情 提交于 2020-01-06 16:01:29
问题 I have a column that has many blanks and entries. I want to take the entries (ignoring the blanks) and move them over to the right once and down twice replacing the contents. I have a feeling you would use the offset function, however I don't know how to write this in VBA. I've only used offset as a formula. Any help would be appreciated... 回答1: First you need to create a loop, that moves through all the values of your range. There many ways to create loops, but here is one example: 'find

Excel data checking

倾然丶 夕夏残阳落幕 提交于 2020-01-06 15:59:46
问题 Excel data checking I have an Excel UserForm which contains the following fields; date , name and work . In the event that the worksheet contains the same date and name pairing, I want data transfer from the Userform blocked. Example A worksheet has one entry: Column A has the date 1/1/2017 Column B has the name john For the worksheet above, the following rules apply: Information can be passed from the UserForm for 3/1/2017 and john . Information can be passed from the UserForm for 1/1/2017

Excel quits on Worksheet_Change Event

瘦欲@ 提交于 2020-01-06 15:59:25
问题 Can someone please point out what's wrong with this snippet of code? Every time a value is changed in the specified range (A1:B6), Excel simply quits with Microsoft Error Reporting dialogue. I am not allowed to uncheck 'Error Checking (Turn on background error checking)' in Excel Preferences. Private Sub Worksheet_Change(ByVal Target As Range) Dim KeyCells As Range Set KeyCells = Range("A1:B6") If Not Application.Intersect(KeyCells, Range(Target.Address)) Is Nothing Then Call Macro1 MsgBox

Transpose every 2nd and 3rd line

﹥>﹥吖頭↗ 提交于 2020-01-06 15:29:06
问题 I am trying to transpose every second and third row to columns B and C and then preferably delete the old rows so that I don't have two unused rows in B and C. I tried recording a macro, which worked for only the selection I made. Then I tried deleting the specific selections and replacing them with an offset range but I keep getting an error in the PasteSpecial line. Sub SortRawData() ' ' SortRawData Macro ' ' Keyboard Shortcut: Ctrl+q ' Selection.Offset(1, 0).Resize(Selection.Rows.Count + 2

Add data to Sharepoint 2013 list from Excel with VBA

て烟熏妆下的殇ゞ 提交于 2020-01-06 15:22:50
问题 I have been attempting to add data to a Sharepoint 2013 list from Excel using VBA with no success. I am using as a template the example that is found all over the internet. Sub Add_Item(ListName As String, SharepointUrl As String, ValueVar As String, FieldNameVar As String) Dim objXMLHTTP As MSXML2.XMLHTTP Dim strListNameOrGuid As String Dim strBatchXml As String Dim strSoapBody As String Set objXMLHTTP = New MSXML2.XMLHTTP strListNameOrGuid = ListName 'Add New Item' strBatchXml = "<Batch

excel vba add form button to each row

做~自己de王妃 提交于 2020-01-06 15:18:53
问题 I have code to add buttons to each row of a spreadsheet, what I want to have happen is when the button is clicked on a given row certain cells will update on that row. My code adds the buttons to the correct row, and when clicked the buttons update the right columns, but each button in every row is only updating the first row, in this case 5, since that is where I start (with variable i). It seems that the .row function is always returning the top row. Any idea why this is the case? Sub

Update cell with a value when form field is selected

我与影子孤独终老i 提交于 2020-01-06 14:18:07
问题 I have an excel workbook with modeless form. The way it's setup is that: each sheet in the workbook has a tab in the form. Each field in these tabs is Linked to a cell in corresponding sheet. So when a value is changed/updated in the form, it is automatically updated in the relevant cell. The way I am doing this is by using the onChange event for each filed which call's a UDF that does the updating. My question, there are a lot of fields in the form and lots more to be added. Is there a way

Update cell with a value when form field is selected

不打扰是莪最后的温柔 提交于 2020-01-06 14:18:05
问题 I have an excel workbook with modeless form. The way it's setup is that: each sheet in the workbook has a tab in the form. Each field in these tabs is Linked to a cell in corresponding sheet. So when a value is changed/updated in the form, it is automatically updated in the relevant cell. The way I am doing this is by using the onChange event for each filed which call's a UDF that does the updating. My question, there are a lot of fields in the form and lots more to be added. Is there a way

How to pass multiple values to stored procedure parameter that running from VBA?

冷暖自知 提交于 2020-01-06 14:15:02
问题 I got situation. I have created VBA that calls SP with 2 parameters. How Can I pass 2 values to each parameter? below code as ex, passing single value to each parameter: cmd.Parameters.Append cmd.CreateParameter("@Class", adVarChar, adParamInput, 40) cmd.Parameters("@Class").Value = "H" cmd.Parameters.Append cmd.CreateParameter("@Color", adVarChar, adParamInput, 40) cmd.Parameters("@Color").Value = "Black" Now I want to pass "M","Yellow" also. How can I achieve this? Do I need to do any

Finding largest number and deleting remaining smallest number

别说谁变了你拦得住时间么 提交于 2020-01-06 14:13:45
问题 I am trying to Delete cell by comparing Names within the same column, If I find the same name, Then make sure name is containing bigger number after forward slash, If I find the bigger number then make sure my C column matching my criteria (NOT Playing). If it is matching then delete all cell which is a smaller number with column c saying Still Playing and keep only bigger number which is saying Not Playing. Any Ideas, I have posted my code but when I am finding a bigger number, it's going