I have a vba code and I want to know the structure of the Excel file (the sheets) on which it is run [closed] - excel

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I have a problem to solve by vba, I find a code that does this task on the internet but I could not understand it, because I do not have the Excel file on which it is run. so my goal is to know the structure of the Excel file (sheets and columns), and especially I do not understand this part:
With Worksheets ("Output of PV")
     .Range (.Range ("_ pv") ....
I say that _pv is the name of a range, but I can not find in the code where is it defined?
My problem is with formula range ("_ pv"), and range ("_ data")
With Worksheets("Sortie de PV")
.Range(.Range("_pv").Offset(0, 0), .Range("_pv").Offset(10000, 100)).Value = ""
EntWith

The Named Range _pv is NOT defined in VBA. It's defined in the Excel Name Manager. You can find the Name Manager in the "Formula" tab of the ribbon.
As for the rest of this code:
With Worksheets("Sortie de PV") is saying: When you encounter, in the lines before the End With an object, method, or parameter preceded with a ., I am referring to this worksheet.
On that worksheet SET the .Value of the Range() where the Row is from first cell in the named range "_pv" and the Column is 10000 rows down and 100 columns over from the named range "_pv"
That second one is a little clunky and could probably just be reduced to something like .Range("_pv").Resize(100, 10000).ClearContents. Also because there is only a single line in that With block, then the With really isn't necessary. So this whole thing could probably just be:
Worksheeets("Sortie de PV").Range("_pv").Resize(100, 10000).ClearContents
If that doesn't work exactly, then referring to the first cell in the "_pv" named range might be better:
Worksheets("Sortie de PV").Range("_pv").Cells(1,1).Resize(100, 10000).ClearContents

Related

I'm not getting the right output in excel [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 days ago.
Improve this question
I need help in pasting values of cell range to another worksheet's next empty cell/row.
Worksheet names - "data" and "test"
Copy values of B2:B15 from worksheet "data"
Paste values to next empty cell in column B of worksheet "test"
This is executed by clicking a button.
Thank you for your help.
I tried tweaking this one, but I really cannot get the output I want.
I found online.
code
This example uses an input.
I don't use text input box, all I need is just to copy what ever in the cell range into the another sheet's next empty cell in specific column.

Multiple answers at once in Excel [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I have a complicated excel sheet with multiple variables to give a single output (I will name this the 'result') via multiple formula in various cells. One cell (I will name it X) can only have 60 possible entries. I would like to know what the 'result' for all 60 options while changing the variables in the other cells.
One way I have thought it could be possible is by having a table with the 60 possible entries in one column (I'll call this column A) and the 'result' in the corresponding cell in the column next to it (I'll call this column B). But I don't know how to get all the 'results', simultaneously in the other column.
I feel like it needs to be a formula like [when X = A1, B1 = 'result'] then filter this down the column.
Can anyone help?!
You can make this by two ways. By filter or pivot table. I find tutorial that can help you.
here is the filter link
https://support.office.com/en-us/article/video-filter-data-in-a-range-or-table-7fbe34f4-8382-431d-942e-41e9a88f6a96
here is the pivot table link
https://www.excel-easy.com/data-analysis/pivot-tables.html

How to write a macro in Excel that will hardcode all the cells in a workbook that contain formulas with the letter "CIQ"? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I am working on a spreadsheet that is pulling a lot of data from Capital IQ (CIQ). I would like to hardcode all these formulas. If somebody that doesn't have the CIQ plugin tries to look at the spreadsheet, all they see is #name and #value. I don't want to hardcode all the cells since some of them are useful to see how they are linked to other tabs. I am looking to hardcode only the cells that contain a CIQ formula.
Thank you for your help!
Miha
Untested from mobile
Sub find()
Dim c as range
For each c in range(“A1:B100”).Cells
On Error Resume Next
If application.worksheetFunction. Search(c.value,”CIQ”) > 0 then c = c.value
Next c
End sub

Vba for Text string + another cell value + text string [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I have a problem. I have simple excel table with pictures that changes number of row every day. I adapted vba code found on internet (I am very new to vba). I wanted to add a string at the first empty cell (last row of the table) and managed that using vba. But the string contains a number that changes every day and I need to update that numer along with the string. The number is number of non empty rows after filter applied and is contained in some cell in the same workbook. How can you make vba that would adapt to what I already have? So it goes like this:
1. Find first empty cell (donne)
2. Select a range from finded cell and merge (donne)
3. Add a text string + number from another cell (the cell contains formula to calculate that number) + another part of text string (this part is my problem)?
Best regard to anyone who can help
I feel like the user has provided enough info and has explained how they arrived at their current roadblock (plus they are new), so I will give them the benefit of the doubt and provide my input.
Code:
Output
ActiveSheet.Range("Whatever cell you want this in").Value = textstring1 & ActiveSheet.Range("Cell with the formula/number you need").Value & textstring2
In the parentheses you would put the cell or range you want the value from for example:
ActiveSheet.Range("A2").Value
Also, instead of hard coding your text strings you can use variables. So, in place of "Test" you could use say variable string1, which you defined above your code and gave a value like so:
Dim string1 as String: string1 = "Test"

Paste Value Based on Formatting [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I'm wondering if it's possible to use VBA to copy the text of a cell instead of the value of a cell.
For example, if cell A1 contains the value 10000, but is formatted in thousands as $10.0, is it possible to set cell B1 equal to the text string $10.0 from A1? I've tried every variation of standard copy/paste without success.
Note: I would like to allow flexibility for various custom formats, e.g. $, %, thousands, millions, etc. I'm running Excel 2010.
To copy only the text which appears in the cell, you will not use the Copy or Paste or PasteSpecial methods at all.
Instead, you can simply assign one cell's value based on another cell's text:
[A2].Value = "'" & [A1].Text
I add the single quote to force Excel to treat the value as a string, otherwise it may misinterpret number formats in "General" formatted cells.
This will work for you.
Range("A1").Copy
Range("A2").PasteSpecial xlPasteValuesAndNumberFormats
Can be achieved with a formula:
="$"&TEXT(A1/1000,"00.0")
then select, Copy, Paste Special, Values.

Resources