?
Solved

Excel vba to place field name from another worksheet into a different cell/worksheet

Posted on 2014-09-30
4
Medium Priority
?
61 Views
Last Modified: 2016-02-11
Hi Experts,

I have some script that I have copied from textpad and pasted into excel.  I need to update the script incrementally where it says "samp1" below and I need to change the select statement in that script as well.  I have all of the field names pasted in one column in sheet2 of my excel workbook and the script is pasted on sheet1.  See example below:

Sheet 1

samp1.abc
samp1.123
samp1.nowIknow
samp1.sql=select * from "the first name in cell a1 on sheet2"

samp2.abc
samp2.123
samp2.nowIknow
samp2.sql=select * from "the first name in cell a2 on sheet2"

samp3.abc
samp3.123
samp3.nowIknow
samp3.sql=select * from "the first name in cell a3 on sheet2"
0
Comment
Question by:daintysally
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 26

Expert Comment

by:ProfessorJimJam
ID: 40353268
can give more details, perhaps an example file?
0
 
LVL 20

Accepted Solution

by:
ElrondCT earned 2000 total points
ID: 40356261
Are you looking for something like this?
Sub OutputLines()
    For i = 1 To 5
        Cells(i * 5, 1).Formula = "samp" & i & ".abc"
        Cells(i * 5 + 1, 1).Formula = "samp" & i & ".123"
        Cells(i * 5 + 2, 1).Formula = "samp" & i & ".nowIknow"
        Cells(i * 5 + 3, 1).Formula = "samp" & i & ".sql=select * from ""the first name in cell a" & i & " on sheet2"""
    Next i
End Sub

Open in new window

0
 

Author Comment

by:daintysally
ID: 40357448
@ElrondCT...yes, that is what I am aiming for
0
 

Author Closing Comment

by:daintysally
ID: 40789734
Thank you, this put me on the right path
0

Featured Post

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question