VB Excel - Print set columns on diff pages - excel

I have been given a very ugly excel document which I need to be able to print the first 4 columns off every time and then loop through each of the next columns so they only print one at a time per sheet as if the first 4 columns were frozen and then each of the others prints off one at a time in turn.
I have tired a number of different approaches to this from hide, unhide to looping and active cells but I cant seem to find the best and most efficient effect way to do it.
The first four columns contain standard headings as titles and then the subsequent ones relate to a specific object - I want to be able to use VB to press a button and print out the heading columns and then effectively each object column on its own page so its like every object has its own page with heading to go into a ring binder file. Hopefully allowing each object to be quickly viewed independently without the data of the other objects if I was viewing the whole spread sheet. Effectively each object on its own page with the default headings, each object is a different column.
I am sure there is a simple way to do this and I am over complicating it!
Any help welcome.
Thanks

Related

Is there a way to enter, save and delete entire row in a scrollable list and reflect the same changes in main data sheet in excel

Fisrt i would like to state that i don't know much about vba other than what i pick up from the internet and forums like this one. I have a problem and i'm hoping some on this forum will come to my rescue.
I'm trying to create a simple equipment maintenance system in excel. I do not want to use the vba user form Because i do not have much knowledge of vba coding.I have two sheets, Sheet1 (called Form) and sheet2 (called Data). So i have craeted an on sheet form on the left of the sheet1 (Form) which i would like to stay visible at all times So to achieve this i picked up a method from the internet of creating a scrollable list (Displaying all data entries from sheet1 (Form), i have also picked up vba code to save and reflect form entries on Sheet1 (Form) on sheet 2, so far so good. Coming to the problem, i would like to make and delete entries directly on to the scrollable list which would also reflect on the data sheet. Another problem i would like to know if possible is how to make the maximum value of the scrollable can increase automatically as data rows increase.
Please HELP!

Create Connection to one raw data file for multiple excel files

I currently have one excel file with four worksheets with data (Name: target value 2022.xlsx). This data is used in multiple excel files to make calculations and to show the values using VLookUp. Until now I copy-paste the values from this one file with four worksheets into all the other files with those four worksheets (and more) when one value changes throughout the year. It also seems to be problematic when a new year begins and a new "target value 2023.xlsx" is required. I tested a lot of ways to make a connection, but nothing seems to be the perfect way:
copy-paste each table via VBA (current way, but I don't want to open every file just because one value changed and click the "Refresh" button)
external reference Cell A1: =[target value 2022.xlsx]Table1!E3 (if one column is deleted, the connection shows #REF!)
Data > New Query > From File > From Workbook (if one column is deleted, the power query doesn't work anymore)
Data > From Text (only works, if all four worksheets are in four seperate csv-files, not optimal)
Data > From Access (seems to be the best way to get the data from four different tables within the database???)
What's the best way to do this, if multiple people use it? The values in "target value 2022.xlsx" change multiple times a year and many users need different files where the data is required. Thank you!

Select Data for excel Graph sees zeroes when I load the data using sql

I have a problem with Excel (2016)/ VBA macros. I am happy to provide more detail or copies of files if required.
In summary this is what is happening:
I have a workbook with five worksheets. Three contain data representing both axes of a matrix (1&2), the cells of the matrix (3), one sheet on which data from sheets 1 to 3 are brought together (4) and - finally - a graph worksheet (5 - based on a range in 4).
The reason I do it like this is that I want to graph parts of the data at a time otherwise it is all too confusing. A simple form is used to choose which column of the data-set to display and to also allow stepping through the list of items to display so just part of the range is in view at a time. Variables are set in cells on sheet 4 (outside the graphed range) when the buttons are clicked on the form. The formulae that populate the graphed range on that sheet use these variables to choose the required data from sheets 1 to 3.
Initially I populated the data in sheets 1 to 3 using macros to read from text files. These files had to be populated from a database before opening the Excel workbook. I decided to "Simplify" this process by changing the macros to query the database directly.
It took a while to get this going and all looked fine. I can see the data in the first four worksheets is populated correctly (including being able to click on the form buttons and change the contents of the graphing range) but the graph sees values of zero in every cell. When I right click on the graph and select "Select Data" and then choose an item in the "Legend Entries (Series)" list in the left-hand box, and the click "Edit", I see the cell ranges of both the Series name and the Series Values are correctly displayed, the preview of "Name" has the correct value but the preview of "Series" shows a string of comma-separated zeroes.
I can switch worksheets to view the "GraphData" on sheet 4 while still keeping the dialogue box open and see the actual cells that are being referred to and they are not 0, 0, 0... they are 78, 69, 44...
Where are the zeroes coming from?
I have even saved the workbook - keeping changes - so the contents of sheets 1 to 3 are kept, put a stop in the "Workbook_Open" macro so it doesn't run, and still I get zeroes when I re-open it.
Sorry to bother folk. I worked out the problem. As usual, there were interesting lessons along the way.
I started out with a query that populated a text file with data from my database. Because I wanted the file to be ingested by Excel as a csv file, the output for each row of the selected data was a single string column containing the keys and the data values with commas between them, the numbers being converted to VARCHAR within the sql so I could concatenate them into the string.
Them when I decided to try using the query directly from Excel rather than having the file step in between, I removed the concatenation operators and the commas and put a comma between them in the sql syntax but didn't remove the conversion to VARCHAR of the numbers.
With QueryTable, when you import a text file, one of the optional properties is an array of codes representing the data types of the incoming data. I assumed that with a direct query, Excel would assign a data type based on content as it does for typed values (unless you specify another). Clearly Excel and the source database exchange information, in addition to the data set itself, that tells Excel the data type of the columns - as sent.
The graphing function was seeing my data as strings so assigned values of zero. I began by putting a Value() around my lookup functions on the GraphData worksheet. That worked but then I went further back and actually changed the Sql so it sent numeric data without conversion to VARCHAR and then it worked without the Value() change.
It never occurred to me that Excel wouldn't just see a number and treat it as such - not that Sql Server would have told Excel it was a string.

Set specific height for all existing/new rows of a table

I have used Excel for quite some time now but only using traditional formulas. Now I am trying to create a more elaborated document for my business using VBA coding to expand my possibilities.
I have done some research and started practicing but found something that I can’t understand how to do yet.
I have a worksheet with a table on it. Since this is a fresh document it has nothing but the header and a blank row below it. What I always did when writing the information was type text in any of the columns that belong to the row immediately below the table (without actually inserting a new row myself). This creates a new row for the table where most of its format is kept, such as text size and formulas. However, I noticed that the row height doesn’t automatically change to that of the previous rows of the table, and changing it manually for each new row is very time consuming.
I would really appreciate it if anyone could share me the necessary Excel VBA code to fix this issue. I have thought of two possible approaches. The first one is a code that automatically sets all the rows of the table to a height of 20 (I want all rows to be the same size so no problem with that), supposing this would also affect new rows as I add them the way I mentioned. The second one would be a code that automatically sets every new row of the table to a size of 20. It doesn’t matter which one you choose, the easiest will be just fine. Thanks in advance.

Excel Turn Chunks of Text Into Columns

I need to find a programmatic way to do the following. Basically, I have a text file with the followoing:
Of course, there is real data in there and there are several thousand different "chunks" like this. First, we would like to collapse Job Title 1 and Job Title 2 into a single line. Then, we need to import this into excel in a row format. Such as:
I've tackled a similar problem at my job, and the data can actually be manipulated purely in Excel. Your first step is to just get it into Excel, open it in Notepad - copy, then paste into Excel - or optionally try to open it. The trick is to use the "blank row" as a trigger for a set or formulas that you just fill down. When it's done you copy all the results over to a new worksheet, and sort so all the blank rows get thrown away. You'll have to hack away at your data and merge the various results next - but that wont be too hard because you should get 3 different kinds of rows (those with 1 job, 2, 3) .. just fix them with a unique formula each. Hopefully this gives you an idea of how to get started:

Resources