excel-vba

Why Error1004: unable to set the NumberFormat property of the Range class?

核能气质少年 提交于 2020-01-16 01:55:11
问题 Why do I get Error1004: unable to set the NumberFormat property of the Range class? Sub ReadFile(fileName As String) Dim projectWb As Workbook Dim lastRow As Long Dim lastRowOutput As Long Dim row As Long Application.ScreenUpdating = False Set projectWb = Workbooks.Open(Range("folderPath") & fileName, False) lastRow = projectWb.Sheets("Beställningar").Cells.Find("*", [A1], xlValues, , xlByRows, xlPrevious).row For row = 64 To lastRow lastRowOutput = ThisWorkbook.Sheets("Output").Cells.Find("*

Can't delete sheet

我是研究僧i 提交于 2020-01-16 01:10:32
问题 I'm trying to open a workbook and delete a sheet from it, but it runs the code without errors, and the sheet is still there... I'm able to modify it, as I changed formulas to values on another sheet. First of all - Yes, I know the "i" variable is set to do 1 iteration. Somehow, now when I open the workbook it says it's locked by me - which I don't even know how to do. So...how can I unlock it? When I go to File-->Info-->Permissions it says 'Anyone can copy, change and modify any part of this

Excel - Filter unique values from Column A and move related values from Column B to other columns

杀马特。学长 韩版系。学妹 提交于 2020-01-16 01:01:10
问题 I have a excel like this Col1 - Col2 A - 1 B - 2 A - 3 B - 4 A - 5 I want to produce an excel from above one as shown below Col1 - Col2 - Col3 - Col4 A - 1 - 3 - 5 B - 2 - 4 Is there a way in excel to do this? Please help 回答1: Here's a way to do it with formulas. It takes a small bit of formatting first though, so perhaps copy your data to a new sheet, then tweak. First, get the unique values from Column A. In your example, these would be A and B . (For long lists, copy column A to some

Need guidance with a VBA function to paste values in Excel

你说的曾经没有我的故事 提交于 2020-01-16 01:00:28
问题 I'm a VBA newbie, but have successfully created a handful of useful Excel Functions. The one I'm working on right now, which seems like it should be simple, is eluding me. I think I'm misunderstanding the syntax, and need some guidance. Consider the following screen capture; I am attempting to create the function in Column E, which is simply the VALUE from D$n. So far, this is as far as I've gotten: Function PASTVALUE(q As String) q.PasteSpecial Paste:=xlPasteValues End Function which, if I

Re-setting all option buttons at once

。_饼干妹妹 提交于 2020-01-15 23:37:27
问题 I have written a code for re-setting all option button on one click but its giving an error, "object doesnt support the property or matter". Sub Add_New_Record() Dim i As Integer For i = 1 To 30 With Sheets("Form") '-- unlock the worksheet .Unprotect .OptionButton(i).Value = False '-- lock the worksheet '.Protect .Activate .Range("Q12").Select End With Next i End Sub Can anyone please suggest me how to fix the code and make the value of all option buttons "false" at one. I know how to do it

Protecting Excel Worksheet Data From Savvy User

混江龙づ霸主 提交于 2020-01-15 23:35:41
问题 I'm creating a excel application that will be distributed to my associates. Based permissions I need to disable access to certain sheets and features. I've been able to protect and hide sheets but a savvy user is able to iterate over hidden worksheets internally or externally to expose data. I need to stop that. Here's the process: When the workbook opens a query to remote database is made to return set of user permissions. Then those permissions are printed to worksheet called "PERMISSIONS".

Loop through each row in a table

牧云@^-^@ 提交于 2020-01-15 22:47:22
问题 I've defined a table as cards (see picture here: https://www.flickr.com/photos/113328996@N07/) I now want a create some VBA code which does the following: Loop through the whole table Count the times it 'hits' "A". I wantto do something like this sub countCards //Open sheets: "sheet1" dim countA as integer countA = 0 //foreach each row in table "cards" if (cells is "A") countA = countA + 1 end if But I can't find the syntax to get this working. Can anybody help me? Dear regards, Marc 回答1: One

Loop through each row in a table

让人想犯罪 __ 提交于 2020-01-15 22:47:09
问题 I've defined a table as cards (see picture here: https://www.flickr.com/photos/113328996@N07/) I now want a create some VBA code which does the following: Loop through the whole table Count the times it 'hits' "A". I wantto do something like this sub countCards //Open sheets: "sheet1" dim countA as integer countA = 0 //foreach each row in table "cards" if (cells is "A") countA = countA + 1 end if But I can't find the syntax to get this working. Can anybody help me? Dear regards, Marc 回答1: One

Excel VBA- Copy and paste text on left after CHAR(10)

时光怂恿深爱的人放手 提交于 2020-01-15 22:27:13
问题 If the following conditions: A1= fsfsdfsdfs qewqeqewqe B1= RIGHT(A1,FIND(CHAR(10),A1&" ")) Then B1 would display "qewqeqewqe". This works only directly into an excel cell. How would I write this line of code given the following conditions above? Something like the below? Worksheets("sheet1").Cells(1,2).value= left(find(CHR(10), Worksheets("sheet1").Cells(1,1),&""))????? I would not be asking if I had not searched for it. All I keep finding is how to do it in an excel file and not the VBA. Any

Retutn only Buisness days in custom date function in excel

六月ゝ 毕业季﹏ 提交于 2020-01-15 21:01:46
问题 I have a date which I will need to increment the date by a day, month or year from the actual date. This is based of a list of fields below and is different per the input. Also each resultant date has to be a business day i.e not a weekend day or a bank holiday. Also if the resultant date is either Dec 25 or Jan 1st the day needs to move forward to the next business day (not a weekend day). I have created this in Excel using a couple of formulas though it is a bit clunky. Below is my data set